Re: [algogeeks] Re: Implement a queue using a stack

2010-04-14 Thread Ashish Mishra
if two stacks then possible otherwise i dont think so On Mon, Apr 12, 2010 at 11:39 PM, Dheeraj Jain wrote: > Here is code and explanation http://geeksforgeeks.org/?p=5009 > > > On Sat, Apr 10, 2010 at 10:18 PM, Rohit Saraf > wrote: > >> hmm... that can always be done ! >> >> ---

Re: [algogeeks] Re: Implement a queue using a stack

2010-04-12 Thread Dheeraj Jain
Here is code and explanation http://geeksforgeeks.org/?p=5009 On Sat, Apr 10, 2010 at 10:18 PM, Rohit Saraf wrote: > hmm... that can always be done ! > > -- > Rohit Saraf > Second Year Undergraduate, > Dept. of Computer Science and Engineering > IIT

Re: [algogeeks] Re: Implement a queue using a stack

2010-04-10 Thread Rohit Saraf
hmm... that can always be done ! -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 On Wed, Mar 24, 2010 at 6:24 PM, Dave wrote: > Please post your results. I'd lik

[algogeeks] Re: Implement a queue using a stack

2010-03-24 Thread Dave
Please post your results. I'd like to study your algorithm. On Mar 23, 11:15 pm, chitta koushik wrote: > yeah i understand that . still wanted to attempt writing a recursive > reverse() stack operation. > > On Wed, Mar 24, 2010 at 9:21 AM, Rohit Saraf > wrote: > > > > > Even when you are wri

Re: [algogeeks] Re: Implement a queue using a stack

2010-03-23 Thread chitta koushik
yeah i understand that . still wanted to attempt writing a recursive reverse() stack operation. On Wed, Mar 24, 2010 at 9:21 AM, Rohit Saraf wrote: > Even when you are writing a recursive function.. you are not using one > stack. > One stack is yours. Other used for recursion. > > Making queu

Re: [algogeeks] Re: Implement a queue using a stack

2010-03-23 Thread Rohit Saraf
Even when you are writing a recursive function.. you are not using one stack. One stack is yours. Other used for recursion. Making queue from a single stack <=> Making turing machine from CFG. -Rohit On Wed, Mar 24, 2010 at 9:18 AM, chitta koushik wrote: > Can we implement it using a single s

Re: [algogeeks] Re: Implement a queue using a stack

2010-03-23 Thread chitta koushik
Can we implement it using a single stack by writing a recursive reverse stack operation ? On Tue, Mar 23, 2010 at 10:18 AM, Sundeep Singh wrote: > Thanks Dave, I didn't think about this... definitely better! > > Sundeep. > > > On Mon, Mar 22, 2010 at 9:08 PM, Dave wrote: > >> Better still. >>

Re: [algogeeks] Re: Implement a queue using a stack

2010-03-23 Thread Sundeep Singh
Thanks Dave, I didn't think about this... definitely better! Sundeep. On Mon, Mar 22, 2010 at 9:08 PM, Dave wrote: > Better still. > To enqueue: push onto stack A. > For dequeuing: If stack B is empty, pop all items from stack A and > push onto stack B. Then pop stack B. > There is no need to p

[algogeeks] Re: Implement a queue using a stack

2010-03-22 Thread Dave
Better still. To enqueue: push onto stack A. For dequeuing: If stack B is empty, pop all items from stack A and push onto stack B. Then pop stack B. There is no need to push remaining items back to stack A. As every item passes through the queue, it is pushed onto stack A, then popped from stack A