[algogeeks] Re: Design a stack to perform push(), pop() and retrieve minimum in constant time.

2009-10-08 Thread Satyam Shekhar
Dave, we don't remove (3,3)... min_query will return 3 stored at the top..ie (9,3).. pop will remove (9,3).. not (3,3) On Thu, Oct 8, 2009 at 8:47 PM, sharad kumar wrote: > 3 is min element then y to return 5??if  u remove 9,3 > 3 at tos 3 is min so y to remove 5 borther dave > > On Thu, Oct 8,

[algogeeks] Re: Design a stack to perform push(), pop() and retrieve minimum in constant time.

2009-10-08 Thread Satyam Shekhar
Try maintaining at every node in the queue the minimum till that node in addition to the value. min() will return the min val stored at the top. On Thu, Oct 8, 2009 at 9:22 AM, Manisha wrote: > > > > @harit > > Maintaining only one data member, minimum will not suffice. As we may > call min() an

[algogeeks] Re: low time complexity data structure for accessing multiple sets

2009-08-29 Thread Satyam Shekhar
You can have constant access time if you store for each data point the corresponding string. Memory used = Num of data points. Or you can have log (Number of Data sets) access time using BST. Memory used = Num of data sets. 2009/8/29 Jayram Déshpandé : > Hi Guys, > > I have data sets as follows >

[algogeeks] Sprague-Grundy function of DAG

2009-03-21 Thread Satyam Shekhar
Hi, I was wanted to know if we can do better than O(V*V) to calculate the sprague-grundy values of DAG? We can achieve O(V*V) by topologically sorting the graph and then iterating through the vertices. Is there any known algorithm to improve this? Regards Satyam Shekhar