URI:
   DIR Return Create A Forum - Home
       ---------------------------------------------------------
       techsuns
  HTML https://techsuns.createaforum.com
       ---------------------------------------------------------
       *****************************************************
   DIR Return to: Puzzles && Algorithms
       *****************************************************
       #Post#: 104--------------------------------------------------
       data structures 
       By: dinesh Date: November 18, 2012, 10:57 pm
       ---------------------------------------------------------
       Give pseudo code for implementing a queue using a single
       stack...
       #Post#: 110--------------------------------------------------
       Re: data structures 
       By: kranthipls Date: November 18, 2012, 11:35 pm
       ---------------------------------------------------------
       I don't think we can do this using a single stack. We need two
       stacks.
       If we can do with only one stack then what is the difference
       between the stack and queue?
       We can use the same for both the purposes.
       #Post#: 114--------------------------------------------------
       Re: data structures 
       By: kpr29 Date: November 18, 2012, 11:41 pm
       ---------------------------------------------------------
       I'M TELLING we can  DO IT...
       #Post#: 116--------------------------------------------------
       Re: data structures 
       By: kranthipls Date: November 18, 2012, 11:48 pm
       ---------------------------------------------------------
       Maybe then I will be waiting for the answer
       #Post#: 117--------------------------------------------------
       Re: data structures 
       By: dinesh Date: November 18, 2012, 11:49 pm
       ---------------------------------------------------------
       What is the problem that you are facing to do so? Share your
       lines of thought for discussion...
       #Post#: 119--------------------------------------------------
       Re: data structures 
       By: kranthipls Date: November 18, 2012, 11:54 pm
       ---------------------------------------------------------
       We can perform only three operations on the stack. That is push,
       pop and top of the stack. But we do not have access to the
       bottom of the stack.
       So in order to perform dequeue we need to push all the elements
       into a new stack starting from the top of the stack and pop the
       last element in the stack.
       #Post#: 121--------------------------------------------------
       Re: data structures 
       By: ravu Date: November 19, 2012, 12:00 am
       ---------------------------------------------------------
       Yeah - with two stacks only it is possible by using operations -
       push, pop and top of the stack,
       pop all the elements from stack1  and push them into stack2,
       then dequeue will be pop on stack 2 and then again pop all
       elements from stack 2 and push them into stack1.
       Enqueue is just push on stack1.
       #Post#: 122--------------------------------------------------
       Re: data structures 
       By: dinesh Date: November 19, 2012, 12:03 am
       ---------------------------------------------------------
       can you think of using a stack already provided to us!!!!!!!!!!
       #Post#: 123--------------------------------------------------
       Re: data structures 
       By: ravu Date: November 19, 2012, 12:06 am
       ---------------------------------------------------------
       Yeah stack 1 is the stack which is already provided for us.
       #Post#: 124--------------------------------------------------
       Re: data structures 
       By: kpr29 Date: November 19, 2012, 12:06 am
       ---------------------------------------------------------
       @Ravu & Kranthi: Perfectly fine correct.............. Lets think
       that only one stack is given and we have to do it..............
       I also dont know.......... Just thinking if we know the size of
       the stack.......... bottom element can be removed rather say
       popped.........
       kp
       *****************************************************
   DIR Next Page