Welcome Message

Hi, welcome to my website. This is a place where you can get all the questions, puzzles, algorithms asked in interviews and their solutions. Feel free to contact me if you have any queries / suggestions and please leave your valuable comments.. Thanks for visiting -Pragya.

January 3, 2011

World War - I Puzzle

A grandfather is telling his grandson stories of world war.

He said :

"At the end of World War 1, I was awarded for my bravery
after saving a group of my men"

"We were fighting in northern France and one of our
enemies threw a grenade at us. I managed to pick it up and
throw it away before it exploded. So right after the war
ended, a General gave me a sword, engraved with the words
'Awarded for Bravery and Valor, A True Hero, World War 1'".

"The grandson thinks about the story for a minute and then
says "Grandpa, that story can't be true!"

How did the grandson know?

December 26, 2010

Program to Shuffle a pack of card in O(n)

public class Shuffle {

public static void shuff(int[] arr) {
for(int i=0; i
int rand  = (int)(Math.random() * arr.length);
int temp = arr[rand];
arr[rand] = arr[i];
arr[i] = temp;
}
for(int i=0; i
System.out.println(" "+arr[i]);
}
}
}

December 23, 2010

MarkIT Telephonic Interview Questions

1. Difference between ArrayList and LinkedList. Why search in ArrayList is faster than in LL. When to use what

Ans : Array List is implemented as an Array and since arrayList is indexed, we just need to go to array+i th position directly. We do not have to traverse the whole list as in case of LL

2. HashCode and Equals contract

3. Difference between HashTable and HashMap
(If have inserted lakhs of objects in a HashTable and these threads simultaneously want to access a method(lets say equals() method)... one thread will accquire lock on the method, so others will have to wait. This will be a performance hit.
This is the reason why HashMap (not synchronised) came into picture. HashTable is legacy datastructure.

4. Difference between IOC and Dependency Injection

5. Difference between Error and Exception. Are all Errors Irrecoverable. (Think about NoClassDefFoundError)

December 8, 2010

java.lang.ThreadDeath

java.lang.Object
          |
java.lang.Throwable
          |
java.lang.Error
          |
java.lang.ThreadDeath (implements Serializable interface)

This Error is thrown by the Thread when the stop method with zero arguments is called.

October 31, 2010

ServletResponse : getWriter() and getOutputStream()

getWriter() : returns PrintWriter Object that is used for writing character text.

getOutputStream() : returns ServletOutputStream Object used for writing binary data in response.

October 28, 2010

Mean - Median - Mode

Mean - Median - Mode are three words which I often confuse.

Mean : Average 
  • Arithmetic Mean (AM) : (a+b+c+....+n)/n 
  •                                                               1/n
  • Geometric Mean (GM) : (a*b*c*.....*n)

  • Harmonic Mean (HM) 
     AM >= GM >= HM

Median : Middle Value
     If we have a set of values, then mean of those can be found by arranging those values in ascending/      descending order and the middle value will be median.

Mode : Most frequently occuring value. Mode may / may not be unique.

September 29, 2010

MaxEmail : Send and Receive Fax by Email

With MaxEmail, you can send and receive fax on your email account.You do not need any Fax machine or dedicated phone line for this. The Fax would come as a PDF in the email. You can also receive an audio file, which will be stored as wav file.

With this, you can also ask for a dedicated Fax number.

September 6, 2010

ECF : Eclipse Communication Framework - Installation

Got to explore ECF - Eclipse Communication Framework (Introduces the concept of communications container)
It is a framework build to integrate Communication into projects. It includes various tools like Instant Messenger, Chat Client , File Sharing, Project Sharing, Simultaneous edits to a file by various developers, Real Time Collaboration etc.
Really nice Communication Framework with plenty of features.


Installation steps :


1. Open Eclipse 3.5 or higher.
2. Open Help -> Install New Software...


3. Then click on Add button on 'Install' window and add the following details:


Name : ECF 3.3
Location : http://download.eclipse.org/rt/ecf/3.3/helios/site.p2





4. Click 'OK'.
This would start the installation. This might take several minutes.

After the installation , you are ready to communicate :)