[algogeeks] Modify Queue Data Structure which returns min in O(1) time.

2010-10-13 Thread malli
A queue data structure has functions enqueue(int x) ( inserts element in right end), dequeue() ( deletes element from left end) functions. These operations take O(1) time. Modify this queue data structure, so that it supports findmin() which returns minimum element of stack in O(1) time. -- You

[algogeeks] Birds on wire

2010-10-07 Thread malli
An interesting puzzle. Assume size of each bird to be negligibly small. Please provide your answers with analysis. Take a wire stretched between two posts, and have a large number of birds land on it at random. Take a bucket of yellow paint, and for each bird, paint the interval from it to its clo

[algogeeks] Re: All numbers in Array repeat twice except two

2010-10-07 Thread malli
e rightmost set bit. > > Now when we take xor of all values where 2nd bit is set(this could be done > as (a[i] & 0010) , we get  6 > Taking xor of all values where 2nd bit is not set yields 4. > > Mukesh Gupta > Delhi College of Engineering > > > > On Mon, Oct 4,

[algogeeks] Largest Rectangle in a binary Matrix:

2010-10-07 Thread malli
Largest Rectangle in a Matrix: Given an n by n matrix with zeros and ones, find the largest sub- matrix full of ones in linear time. I was told that a solution with O(n) time complexity exists. If there are n^2 elements in a n X n matrix how does a linear solution exist? -- You received this m

[algogeeks] All numbers in Array repeat twice except two

2010-10-04 Thread malli
I have an array. All numbers in the array repeat twice except two numbers which repeat only once. All the numbers are placed randomly. Goal is to find out efficiently the two numbers that have not repeated with O(1) extra memory. Expecting linear solution. -- You received this message because y

[algogeeks] Re: Finding all loops in a directed graph

2006-10-22 Thread malli
using DFS the loop would get detected more than once. If we use DFS a loop would be detected 'n' times if there are 'n' nodes in the loop. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To

[algogeeks] Finding all loops in a directed graph

2006-10-22 Thread malli
Hello All. How can I detect all loops in a directed graph? I would like to detect the starting node of the loop as well as the closing edge of the loop. Thanks in Advance. Regards, Mallikarjun. --~--~-~--~~~---~--~~ You received this message because you are s