Thursday, 7 February 2013

Pattern Matching implementation in JAVA implementing Directory

Pattern Matching implementation in JAVA implementing Directory

import java.io.*;
class Mat
{
  public String patt;
  public int flg=0;
  public Mat(String p)
  {
      patt=p;
  }
  public void chk(File f) throws IOException
  {
        if (f.isDirectory())
        {
            File[] lf = f.listFiles();
            for (int i = 0; i < lf.length; i++)
            {
            chk(lf[i]);
            }
        }
        else
            srch(f);
  }
  public void srch(File f) throws IOException
  {
          FileInputStream fstream = new FileInputStream(f);
        DataInputStream in = new DataInputStream(fstream);
        BufferedReader brd = new BufferedReader(new InputStreamReader(in));
        String strLine;
        int l=0;
        while ((strLine = brd.readLine()) != null) 
            {
            l=l+1;
                int n=strLine.length();
                int m=patt.length();
                char p;
                char t;
                int s=0;
                int    i=0;
                int j=0;
                while(i<n && s!=1)
                {
                    t=strLine.charAt(i);
                    p=patt.charAt(j);
                    if(p==t)
                    {
                        i++;
                        j++;
                        if(j>=m)
                        {
                            s=1;
                        }
                    }
                    else
                    {
                        j=0;
                        i++;
                    }
                }
                if(s==1)
                {
                    System.out.println("Found Pattern at Line "+ l+" in file" +f);
                    flg=flg+1;
                }
                s=0;
            }
  }
}
  
class Pat
{
    public static void main(String[] args) throws IOException
    {
        String patt;
        File f=new File("D:\\Sameer\\Pat.java");
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        System.out.println("enter pattern");
        patt=br.readLine();
        File f1=f.getParentFile();
        Mat m=new Mat(patt);
        m.chk(f1);
        System.out.println("Pattern Found "+m.flg+" times");
    }
}
       

Monday, 4 February 2013

Pattern Matching using Java

import java.io.*;
class Pat
{
    public static void main(String[] args) throws IOException
    {
        String patt,strLine;
        int l=0,f=0,count=0,fc=1;
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        System.out.println("enter pattern");
        patt=br.readLine();
        while(fc<6)
        {
        FileInputStream fstream = new FileInputStream("textfile"+fc+".txt");
                DataInputStream in = new DataInputStream(fstream);
                BufferedReader brd = new BufferedReader(new InputStreamReader(in));
        while ((strLine = brd.readLine()) != null)  
            {
            l=l+1;
                int n=strLine.length();
                int m=patt.length();
                char p;
                char t;
                int s=0;
                int    i=0;
                int j=0;
                while(i<n && s!=1)
                {
                    t=strLine.charAt(i);
                    p=patt.charAt(j);
                    if(p==t)
                    {
                        i++;
                        j++;
                        if(j>=m)
                        {
                            s=1;
                        }
                    }
                    else
                    {
                        j=0;
                        i++;
                    }
                }
                if(s==1)
                {
                    count++;
                    System.out.println("Found Pattern in File textfile"+fc+" at Line "+ l+" at position "+(i-j+1));
                    f=1;
                }
                s=0;
            }
            if(f==0)
                    System.out.println("Pattern not found ");
            else
                    System.out.println("Pattern count= "+count);
            fc++;
        }
    }
}


Note: Before executing this program create 5 text files with name textfile1.txt, textfile2.txt, textfile3.txt, textfile4.txt, textfile5.txt.

Friday, 11 January 2013

How to Prepare for GATE 2013 Exam?


The Graduate Aptitude Test in Engineering (GATE) is an All-India Examination conducted by the Seven IITs and IISC, Bangalore, on behalf of the Ministry of Human Resources Development (MHRD), Government of India. GATE is undertaken to admit students in Postgraduate Engineering Programs at the National level. One of the IIT or IISc is selected every year to conduct the test.

GATE is basically an exam that assesses your fundamentals. The questions asked in the exam are mostly derivations of the fundamentals. While preparing for GATE, you should go step-by-step. Firstly, you need to clear your basics and then test yourself if you have got them right. After this, you should take a mock test among your competitors to see where you stand.

Thursday, 3 January 2013

Dijkstra algorithm's implementation in java (From one source to all the other nodes in Graph)


import java.io.*;
class Tnode
{
int prev;
int len;
char label;
boolean vis;
public Tnode(char lab)
 {
   label = lab;
   prev=-1;
   len=100000;
   vis=false;
 }
}

Tuesday, 1 January 2013

EAMCET Counselling procedure


Stages in AP EAMCET Web Counselling 2013


EAMCET Notification:

APSCHE will be published the EAMCET web Counselling notification during June-July in all the newspapers. Verification is done in help line center. Candidates who fail to report for Certificates verification will not be considered for allotment of seats in any of the colleges.

Certificate Verification:

Document to be produced:

  • EAMCET 2013 Hall ticket
  • AP EAMCET 2013 Rank Card
  • SSC Original Certificate or Marks Memo
  • Intermediate Certificate
  • Study Certificates for 10th Class to Intermediate.
  • Caste Certificate of SC / ST / BC / Minorities (Except OC Students)
  • Income Certificate issued by MRO
  • PH/NCC/CAP/Sports and Games Certificates (if applicable)
  • Transfer Certificate of Intermediate

Best geography books for UPSC prelims, mains

This post is intended to clear the confusion that prevails among the aspirants over how to prepare for UPSC geography and the best books f...