Saturday, September 18, 2010

How to find shortest common superstring ?

Given list of small words and a big word, how to find smallest substring from a big word which contains given list of small words?.

Find universal vertex in given graph represented as adjacency matrix.

How to find universal vertex in a graph represented as adjacency matrix in o(V) time.

Universal vertex has |V|-1 incoming edges and 0 outgoing edges.

how to find binary tree is symmetry or not?

how to find binary tree is symmetry or not?

There is a stream of input coming. How will you randomly pick k elements from it?

There is a stream of input coming. How will you randomly pick k elements from it?
(Reservoir algorithm)

Given an array how will you shuffle it?

Given an array how will you shuffle it?
(Algorithm proposed by Knuth)

Find number which occur more than n/2 times in an array?

Find number which occur more than n/2 times in an array?
Find number which occur exactly n/2 times in an array?

o(n) time and o(1) space complexity.