Pop each element and en-queue it twice and de-queue it once. When stack is empty the front of the queue will be middle element.
On Mon, Aug 22, 2011 at 4:01 PM, Ankur Garg <[email protected]> wrote: > Find the middle of the stack..(Time complexity should be minimum) > > > Stack is not implemented as Linked List ...u have normal stack with > push,pop and top > > How to do this ?? > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
