Hi Guys,
I am stumbled by this question. The following is my approach:
Lets say the two nodes are node1 and node2
For any node (lets say node1), find the path from Root to
node1 and store it in an HashMap
For the other node node2, find the path from root to node2, and while traversing back,
check if any of the nodes are ...
Hey
today I was in a job interview where they gave us a tree with unknown structure(could b not binary) and i was asked to insert it to a database in a certain order where I could turn back the db into tree and show I have done it using ER model, every node in the tree has two data members data1 and data2
can someone answer or give me...
Given 100 GB integer Data on Hard Disk with RAM amounting to 2 GB, how to sort the integers with minimal disk operation. Here fetching one number from disk is considered as one disk operation( though in reality a block of data can be fetched).
We can use additional space on the disk for temporary storage and no need to consider the oper...
A helicopter drops two trains, each on a parachute, onto a straight infinite railway line.
There is an undefined distance between the two trains.
Each faces the same direction, and upon landing, the parachute attached to each train falls to the ground next to the train and detaches.
Each train has a microchip that controls its motion....
Write a time efficient C program that takes two strings (string a, string b) and gives the first occurence of string b in string a.
...
In an interview question, I saw this. How inverse the content of this list without loose the references.
List<string> list = new List<string>() {"AA", "BB", "CC" };
Update :
The question is more like this, you have :
public void ReversedList<T>(IList<T> listToReverse)
{
// To be implemented
}
sample the list has 1,2,3,4 and mus...
What are some of the common strategies used for data access?
Can LINQ be called a strategy?
...
I was browsing through some interview questions and stumbled upon this. It got me tearing my hair apart.
Does anyone know how to implement a stack using queue?.
...
Hi Guys,
This was asked in one of the interviews and i cant seem to find any clue about it. The question is:
I have 40 x 20 screen, and i want to store these pixels in a byte array so that i can reconstruct this screen again from the byte array. The size of byte array is 100bytes.
Another way of looking at it is. How do we store a si...
One Interview question i was asked in an interview and i was not get an solution.
Following is the sample paragraph and our program should give the hyperlinks for the words which mathes
"Network protocol Driver- A net-protocol fully Java technology-enabled driver translates JDBC API calls into a DBMS-independent net protocol which is t...
Hi,
I was asked this question in an interview and I gave various solutions but the interviewer was not convinced. I am interested to find a solution. Please throw in your views :
Q: Write an efficient data structure to implement the shuffle in an ipod. It must play all the songs, each time in different random order, the same song shou...
Hello,
Can you please help me solving this one?
You have an unordered array X of n integers. Find the array M containing n elements where Mi is the product of all integers in X except for Xi. You may not use division. You can use extra memory. (Hint: There are solutions faster than O(n^2).)
The basic ones - O(n^2) and one using divi...
Possible Duplicate:
Algorithm: How to tell if an array is a permutation in O(n)?
I was asked this interview question at Microsoft, and it's been bugging me that I haven't been able to solve it. Does anybody have any ideas?
You're passed an array with n integers in it. Each integer is between 1 and n (inclusive). These numb...
I answered that it would depend on a variety of factors including network latency, packet creation and collation etc. But the interviewer wanted a specific number, to which i answered something like 10 Secs :) ( > 8 secs ). Is there an exact formula for this?
...
Jessica asked a viral question ( link ):
You're passed an array with n integers
in it. Each integer is between 1 and n
(inclusive). These numbers are not in
sorted order and there may be
duplicates or missing numbers.
The problem is to figure out if there
are any duplicates in the array in
O(n) time and O(1) space wi...