Buddha

Buddha
Seek

Wednesday, February 23, 2011

Interview Questions - 2

Some more questions:

Type: Data Structures
Company Type: Web, Software, e-Commerce

1. Given is a linked list, in which the Node data is the address of another node (e.g. Data of node 3 is storing address of node 5, data of node 5 is storing address of node 2, etc). How can you copy this linked list ?

Catch is when you copy memory changes, hence the data should change accordingly.

2. Given a Directed Graph, design an algorithm which can detect if there is a loop or not.

3. Given a Binary tree, where each node stores a certain value, find the average at the node.

4. Given an unsorted array, a number 'k', find how many pairs in the array sum up to the value 'k' in the most efficient way. Time complexity should be O(n).

5. Given 2 sorted arrays, and 1 array big enough to accomodate the other array [enough empty space], write a program to get the final array in O(m+n).

No comments: