Recent Interview Questions
Describe the SOA principles / Web Service standards follow when developing web services
Write a method to create new tree with same structure but the values of each node will be sum of their descendents (sub tree). The leaf nodes will become 0. So if the tree is 50 30 10 40 60 55 75 (PreOrder) then new tree should be 270 50 0 0 130 0 0(PreOrder)
What's the difference between a Linked List and an ArrayList and give me an example of when to use which
What are hashmaps and how do they work?
Tell me about memory allocation (stack vs. heap)
What is the difference between Java and C++?
Given a binary tree return the new binary of given depth.
Example:
0 - 3 -- Should return full binary tree from root to height 33 - 4 -- Should return full binary tree from height 3 to 4
A king is about to give a party in 24 hours. For the party they have arranged drinks which will be served through 1000 barrels. Out of jealousy , some one near to king has poisoned one of the barrels. The poison is so strong that even a drop can kill a person. But results are not immediate. A person may die from 13 to 20 hrs. Now king has a duty of finding that barrel. He has 24 hours with him. And he has unlimited prisoners on which the drinks can be tested. Find out the maximum prisoners he would need to find out that barrel.
What data structure to use for finding free parking spot in Parking Lot program? Assume there are million of parkings.
Given a stack of glasses like :
v
vv
vvv
vvvv
.
and a person filling water from the top using a jug. Given that the volume of jug is V , and volume of each glass is 'v' . Write code to find :
1. Number of glasses fully filled
2. Number of glasses partially filled (and what different categories they'd fall in based on half-filled/75% filled etc.)
3. Level to which water would reach.Hint : glasses in center will fill up faster than those away from center.
Print a binary tree in level by level in Zig-Zag manner
Given n points in 2D space find k points nearest to origin
write a function which takes 7 digits (last 7 nos of a 1800 number), and return 2 words formed out of the last 7 digits. i.e. 1800 GotCard (Got and Card are the two words to be returned). There could be multiple possible pairs of words - return any 2
The root node in the tree is equal to sum of its all descendants and the leafs are assigned value 0, so if your tree is something like 10
20 30
40 50
output will be
140
0 90
0 0
Given a queue with functions as enqueue(), dequeue(), and findmax(). You can use these functions any time. The findmax() should return the largest value in the queue at that point. You can use auxiliary space.
Implement the queue with given operations. Find the max value in the queue.
Do a merge of two binary trees and tell what the complexity of the merging is. The trees consist of m and n nodes respect.
Reverse a stack without using extra stack (i.e. doing in place reversal). (hinted about using double recursion).
Delete a given node of a linked list, when you do not have info about the head or any other node.
The prototype of the function is -
void delete (Struct node* x)
where x is any arbit node of a linked list.
Given a graph (consider it to be a mxn grid). The nodes are node of a binary tree with left and right pointers. The start point (A) is at the left upper corner and the end point (B) is at right bottom corner. Each node points to its adjacent nodes in the grid (the right pointer points to the node on the right and the left points to the node just below it). The nodes at the lower and right edges will have child as null (right null for the right side edge and left null for the bottom edge). The end node at B is having both as null.
How many paths are possible which can lead you to B, if you start from A?
Which Data structure is used in window search...??
1. Who is the (which process) the responsible for windows
2. updates ? How these windows 'Run' (winKey+R) commands work ?
3. Why the run commands won't work for user installed applications ? Any way to do so ?
What does a packet contains, when it is send from source to destination ? How does a packet routes to one NW to an other ?
Some questions on LINUX command level,
A. command to find RAM memory space occupied by each process.
B.What does 'top' command do ?
Given some file sharing scenario & asked to give negative test cases as many as possible ?
Ans: Here he himself was not clear about scenario, was mixing up with Wins functionality & his scenario.
You have a 2 liter & 5 liter jugs and a tank of milk. So using these 2 jugs get 4 liter milk in 5 liter jug ?
Ans: 5-3 =2 (take 3 liters frm 5 and put 2 in 3 liter jug); 5 -1 = 4 (again take 5 liter & fill remaining liter in 3 liter )
Logic to print number and number of duplicates of that number in a given array list ?
Ans: It's very easy if you two for loops, anyone can try out & get it in seconds.
(1) Working flow of DNS & DHCP protocol ?
Ans: Yeah it's routine question, explained in my way.(2) How does DHCP generates a lease with client name, by association with DNS.
Ans: With DHCP option DDNS updates, explained it. He was bit happy here.
Search sub string in a big string.
You have 1000 pairs of nuts and bolts all of different sizes. 2 nuts can not be compared and 2 bolts can not be compared with each other. pairs of Nuts and bolts are removed and mixed with each other. How will you arrange them now with lowest complexity .. (hint -> USe quick Sort).