Wednesday, 27 August 2014

Longest Common Subsequence in Java using Dynamic Programming

In case you find some error feel free to comment.


/*
I haven`t refactored the code for words with spaces
This Program uses Dynamic Programming Approach
*/
class LCS
{

   public static void main(String args[])
   {
      System.out.print("Enter First String : ");
 String x=System.console().readLine();
 System.out.print("Enter Second String : ");
 String y=System.console().readLine();

 char[]xArray=x.toCharArray();
 char[]yArray=y.toCharArray();

 int xSize=xArray.length;
 int ySize=yArray.length;

 int lcs[][]=new int[xSize+1][ySize+1];
 String marks[][]=new String[xSize][ySize];

 for(int j=0;j<=ySize;j++)
 {
    lcs[0][j]=0;
 }
 for(int i=0;i<=xSize;i++)
 {
   lcs[i][0]=0;
 }
 for(int i=1;i<=xSize;i++)
 {
     for(int j=1;j<=ySize;j++)
 {
    if(xArray[i-1]==yArray[j-1])
{
  lcs[i][j]=lcs[i-1][j-1]+1;
  marks[i-1][j-1]="D";
}
else if(lcs[i][j-1] >= lcs[i-1][j])
{
  lcs[i][j]=lcs[i][j-1];
  marks[i-1][j-1]="L";
}
else
{
  lcs[i][j]=lcs[i-1][j];
  marks[i-1][j-1]="U";
}
 }
 }
 /*
 System.out.println("\nLCS Matrix is : ");

 System.out.println();
 for(int i=0;i<=xSize;i++)
 {
 
   for(int j=0;j<=ySize;j++)
{
 System.out.print(lcs[i][j]+"\t");
}
System.out.println();
 }
 */

/* System.out.println("Marks Matrix is :");
 for(int i=0;i<xSize;i++)
 {
   for(int j=0;j<ySize;j++)
{
 System.out.print(marks[i][j]+"  ");
}
System.out.println();
 }
 */
 int i=xSize-1;
      int j=ySize-1;
      System.out.println("----------------------------------------------");
      int counter=lcs[xSize][ySize];
 System.out.println("Longest Common SubSequence Length is :"+counter);
 System.out.println("----------------------------------------------");
      char[]lcsArray=new char[counter];
      int fill=0;
      int seen=0;
 while(seen != counter)
 {  
     // System.out.print(marks[i][j]+"  ");
      if(marks[i][j].equals("U"))
  {
     i=i-1;
  }
  else if(marks[i][j].equals("L"))
  {
     j=j-1;
  }
  else
  {
      lcsArray[fill]=xArray[i];
  fill++;
      i=i-1;
  j=j-1;
 seen++;
  }
 
 }
 System.out.print("Longest Common SubSequence is : ");
 int lcsLength=lcsArray.length;
 for(int k=0;k<lcsLength;k++)
 {
    System.out.print(lcsArray[lcsLength-k-1]);
 }
 System.out.println();
 
   }

}

Thursday, 21 August 2014

Passed Oracle Java EE 6 Web Component Developer 1z0-899 Exam

First of all thanks to Almighty Dear Allah . 

Today I took the exam and was able to pass it with 87 %. Thanks to Kathy , Bert and Bryan for writing the book for this exam. 
I am thankful to Piotr Nowicki for his great questions related to Servlet 3.0 stuff ,Nikko for his hard work in preparing questions for this exam they are really helpful . 
Big thanks to ranchers Bibeault , Tim , Ulf and list goes on. Thanks to KT for again helping me out with Credit card. 


I want to share some tips for those who are preparing for the exam. 

I read the Head First Jsp Servlet book . Did the exams given at the end of every chapter. And I was doing quite good. 
As with any other certification exam you need practice . 
Lots of material is already available here Scwcd Links , first time I used Enthuware and It is quite good. It will give you confidence to appear for the real test. Initially I find hard to remember all the API , once I made my own notes it was easy to remember them. 

My scores in enthuware test studio 

Test 1 72% 
Test 2 74% 
Test 3 82% 
Test 4 68% 
Test 5 79% 
Test 6 84% 
Test 7 79% 
Test 8 79% 
Test 9 81% 
Test 10 80% 

Don`t be lazy in making your own notes after taking mock tests. And don`t hesitate to try the code yourself and ranchers will be there to answer your silly questions. 

Regarding the real exam it gives more preference to JSTL ,Jsp standard actions , MVC , Things you can do with DD . Annotation questions was very easy , it will be easy pick for you once you go through mock exams. 
Memorize the API well if you want to score more. 

And when you feel ready , go for it . 

Knowledge should make us humble not arrogant. 
Stay silent and let your success make the noise


You can read it at coderanch also coderanch

Friday, 18 April 2014

How to pass 1z0-047 sql expert exam

Bismillahir Rahmanir Raheem.

First of all, this exam title attracts many guys looking for some certificate.
Because the title specifies you as SQL expert guy.

To pass this exam you have to score atleast 66% out of 70 questions which means about 47 correct answers. 

After doing my Java Programmer certificate  I wanted to have this title.
So I purchased Steve O' Hearn book , which is very good one.

I already had some knowledge of SQL , but not much only about create,insert,update,delete and that also , not in depth knowledge.

It was not only the certificate , I also wanted to study sql in detail.

 What I used as Study Material

I prepared from Steve O'Hearn SQL expert exam book , this book does not contain everything.
Some of the topic is not there in this book but this is not much of issue , you can read it somewhere else
Its really not an issue.
I also used Jason Price 11g Database administrator book
and Roopesh Ramklass ,John Watson 11g SQL Fundamentals book 
And I spent time searching on internet also , when I was not sure about some topics.
What is not there in Steve`s Book
View with grant option , read only option is not in this book
Alternative quote operator is not in this book
Single and Double Ampersand Substitution operator are not there in this book.
Although Updateable view is there in the book but you might not understand it .
And It might be possible that you don`t understand what you read from the book
topics like hierarchical retrieval It took me quite a time to understand how it works and prior keyword

Which topics took long time for me to understand
Various Timezone functions
Hierarchical retrieval , Reporting Aggregated data using Group Functions
Subqueries
Flashback Feature

Yes ! You can pass this exam 
Yes you can pass this exam. Yes exam is tough ,but you can still pass this exam.
All you have to do is to study hard ,  practice .

---------------Please Don`t Take this exam Lightly------------
If you take it , there is good amount of probability that you will fail  this exam

How much Time it will  take
I started one year before ,but not able to study regularly.
In between studied the book and left studied and left studied and left.
But then eventually I made My mind no matter what I am going to take this test in first week of April
I read some other guys stories , they only prepared for 1 months or even a weak or two.
And wrote the paper and passed it.

Don`t Hurry
Yes Don`t hurry.
It might happen that you get frustrated by keep studying books .
And not able to feel that confidance to pass the exam.
Don`t hurry by taking chance , hoping that you will pass this exam.
If you have good knowledge and lacking in some topics then you can still hope , but by not preparing for it and then hoping that you will pass this exam .I don`t think so thats going to happen
Take your time

About Real  Exam 
Two hours will be enough to answer every question
I was able to answer all question and review some questions .
But some questions were very ambiguous and that took some of my exam time.
In some questions not a single options seems to  be correct but then question asks you to select two correct answer , it was very scary.
So except ambiguous questions on exam and aim for scoring 100%.
When I left the exam center I felt and thought I failed this exam.
As I was not sure of many of my answers.
But with the grace of Allah I was able to pass.
I nearly passed this exam with 69% and I was aiming for 100%.

Good luck for your preparations , Believe in yourself and Go for it.