For third round they flew me down to Chennai and there I had four rounds:
Round 1 : This round went for approx 1 hr.
Q1: They asked me about the product i was working on. They asked me if i would have the creator of the product what design patterns i would have used? What are the loop holes in this design? blah blah blah. I think these questions were more on the specific project than on generic interview as such. but this was the only interview where i was asked about Synchronization, threads and other java/j2ee stuff.
Q2: If you have been given a currency format which is of the American standard then how will you write a regular expression for the same. the format examples $110,000,000 or $1,000,000.
Solution: Though I didn’t know much of regular expressions and to start with i wrote more of finite automata machine than regular expression, but in the end I was able to produce the desired result.
Q3: Pre-order of a binary tree without recursion?
Solution: Easy solution by using stacks.
Round 2 : This round went for approx 1.5 hrs. This was one of the most amazing rounds. It started with all amazing stuff on what I do , I read, my hobbies , if i am self motivated on reading about new technologies if yes then what and so on so forth. I think I solved just one question. And total duration was 1.5hrs!!!
Q1: You are given a tree and a pointer to one of its node.
One can call lock or unlock functionality on this node.
LOCK : There can be two outputs to this method "lock" i.e. true when we were able to lock this node and false when we were not able to lock this node. The condition is that if the node which needs to be locked has a parent which is already locked then one can’t lock that node. Also if any of its successors are locked then also one can't lock that node.
UNLOCK: If that node is locked then unlock it.
Now we need to store some information in the nodes. So I was asked to design the data structures of the nodes which will be helpful to me to store information.
Then this question went on from binary tree to n-ary tree.
Solution: Will be posting soon.
Round 3 : This was the great round. Loads of questions.
Q1:
Q2:
Q3:
Round 4:
Q 1: Difference between inner and outer join.
Q 2: One puzzle. Your are participating in a game show. It has three doors, which have a goat, a dog and a merc behind them. Now you have select one door. It is kept closed. Now the anchor selects one door. He makes sure that it is not the one which has merc behind it. Now you are given an option to go with the your first selection or select a new door. What will you do?
Solution: I will select a new door. He asked why? I explained using probability.
Q 3: To calculate number of petrol pumps in Chennai.
2 comments:
1.2. currency format : ^\$([1-9]{1}[0-9]{0,2}(\,\d{3})*)$
1.3. Pre-order of a binary tree without recursion?
void PrintPreOrder(PTreeNode root){
Stack S = new Stack();
if(root != null){
S.Push(root);
}
While(!S.Empty()){
PTreeNode currentNode = S.Pop();
Print(currentNode);
if(currentNode.Left != null) {
S.Push(currentNode.Left);
}
if(currentNode.Right != null) {
S.Push(currentNode.Right);
}
}
}
2.1 You are given a tree and a pointer to one of its node.
One can call lock or unlock functionality on this node.
Solution : For n-ary tree, Lockable property can be attached to node.
Lock Unlock functionality would also update the Lockable property for its immediate children.
Consider a given tree node. check node.Lockable property,
If its true then update all immediate children with Lockable=True. return true.
If its false, imlies that One of its parent hieracrachy is having un-locked node. Hence, cannot be locked, return false
This will also handle repeated operation of Lock-Lock on same node.
Regarding puzzle, I believe to opt for either of the remaining two gates, As we didn't get any lead with anchor disclosing one gate without merc. Probability of selecting a gate without a merc among remaining two gates would be 1/2. Hence, I can choose either of two gates.
Please help me understand where I missed the link.
Thanks
Ankush
Won't it be good to push the right child first and the left child then cause stack will will give you the same in reverse order when you pop.
Post a Comment