Getting Reverse The Order Of Element Using Two Stack

Getting Reverse The Order Of Element Using Two Stacks

Page 1 of 1

1 Replies - 10855 Views - Last Post: 02 March 2008 - 12:39 PM Rate Topic: -----

#1 lokegupta   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 02-March 08

Getting Reverse The Order Of Element Using Two Stack

Post icon  Posted 02 March 2008 - 11:21 AM

pls help me on topic Getting Reverse The Order Of Element Using Two Stacks
Is This A Good Question/Topic? 0
  • +

Replies To: Getting Reverse The Order Of Element Using Two Stack

#2 NickDMax   User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2255
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Re: Getting Reverse The Order Of Element Using Two Stack

Posted 02 March 2008 - 12:39 PM

Well... odd. To reverse the order of elements in a list, you really only need 1 stack. See a stack is a first in - last out structure. So if you push the first element, followed by the second and so on, then when you reach the end you pop the elements off, the last one pushed into the stack will be the first out, and the first one pushed in will be the last on poped out.

So what is the second stack for?

Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Post your code like this: :code:

Thanks.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1