wu :: forums
« wu :: forums - Queue using 1 stack »

Welcome, Guest. Please Login or Register.
May 19th, 2024, 3:57am

RIDDLES SITE WRITE MATH! Home Home Help Help Search Search Members Members Login Login Register Register
   wu :: forums
   riddles
   cs
(Moderators: ThudnBlunder, Icarus, SMQ, towr, Grimbal, Eigenray, william wu)
   Queue using 1 stack
« Previous topic | Next topic »
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print
   Author  Topic: Queue using 1 stack  (Read 2932 times)
computer
Newbie
*





   


Posts: 5
Queue using 1 stack  
« on: Feb 11th, 2009, 9:14pm »
Quote Quote Modify Modify

Can a queue be implemented using a single stack ?
IP Logged
johny_cage
Full Member
***





   


Gender: male
Posts: 155
Re: Queue using 1 stack  
« Reply #1 on: Feb 11th, 2009, 11:24pm »
Quote Quote Modify Modify

if it can be made, then why there are two different entitiesHuh  Shocked
No, it can not be done. You will require two stacks to implement a queue.
IP Logged
nks
Junior Member
**





   
Email

Gender: male
Posts: 145
Re: Queue using 1 stack  
« Reply #2 on: Feb 12th, 2009, 12:31am »
Quote Quote Modify Modify

Quote:
No, it can not be done. You will require two stacks to implement a queue.

 
You can even simulate a queue using only one stack. The second (temporary) stack can be simulated by the call stack of recursive calls to the insert method.
IP Logged
towr
wu::riddles Moderator
Uberpuzzler
*****



Some people are average, some are just mean.

   


Gender: male
Posts: 13730
Re: Queue using 1 stack  
« Reply #3 on: Feb 12th, 2009, 1:02am »
Quote Quote Modify Modify

on Feb 12th, 2009, 12:31am, nks wrote:
You can even simulate a queue using only one stack. The second (temporary) stack can be simulated by the call stack of recursive calls to the insert method.
Making recursive calls requires a second stack -- the function stack.
IP Logged

Wikipedia, Google, Mathworld, Integer sequence DB
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print

« Previous topic | Next topic »

Powered by YaBB 1 Gold - SP 1.4!
Forum software copyright © 2000-2004 Yet another Bulletin Board