Interview Questions 5

1. Find all palindromes in a string.

2. Given two strings we have to calculate count of all common subsequences of 2 in 1st string.

3. Connect the leafs in a binary tree and return a reference to the first of the linked leafs. This would allow clients of this API to subsequently traverse the leafs. The API has a fLR flag indicating if the leafs should be connected from left-right (fLR = true) or from right-left (fLR = false).

Please implement the following API:

public Node ConnectLeafs(Node root, bool fLR)

Parameters:
Node root – a reference to the root of the tree
bool fLR – direction of leaf liking.

4. Write a function for the following scenario:
Given a number determine wether the number is sum of consecutive positive integers,if it is not return false else return true. conscutive integers can be from 2 to n

5. Given an n X n array with rows sorted and cols sorted, find the number of negative elements in most efficient way.

6. In our indexes, we have millions of URLs each of which has a link to some page contents, that is, URL->contents. Now, suppose a user types a query with wild cards *, which represent 0 or multiple occurrences of any characters, how do you build the indexes such that such a type of query can be executed efficiently by finding all corresponding URLs->contents efficiently. For example, given a query http://www.*o*ve*ou.com. You need to find iloveyou.com, itveabcu.com, etc.

7. Design a data structure with the following properties.
a. Insert in O(logn)
b. Delete in O(logn)
c. FindMin in O(logn)
d. FindMax in O(logn)

8. How will you find the number of all possible common subsequences between 2 given strings.

Advertisements

About Avi Dullu
Jaako rakhe saiyan, maar sake na koi!

One Response to Interview Questions 5

  1. Divya says:

    2 nd 8 please provide example for these. I m nt getting the questn..
    7. avl tree or red black trees
    6. plz giv some hint for this one..

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: