Stack

This is a discussion on Stack within the C++ Programming forums, part of the General Programming Boards category; what are stacks? For what are they good? when should i use them and how are they implemented?...

  1. #1
    Registered User
    Join Date
    Apr 2006
    Posts
    8

    Stack

    what are stacks? For what are they good? when should i use them and how are they implemented?

  2. #2
    Anirban Ghosh
    Join Date
    Jan 2006
    Posts
    278
    Stack is an Abstract Data Type,not an data structure as most books say!! as u can implement it with array , list etc. It obeys LIFO(Last in Fast Out) rule. It is used extensively in programming where u need to insert data items and retrieve them in such a way that the last item is got when a POP() operation is called.

    Operation on a stack:
    1. Push() : 2 insert data item
    2. Pop() : 2 delete the last item inserted
    3. Peep() : 2 see the last item inserted
    4. Show_stack() : 2 see the contents of the stack

    Try 2 implement these in C/C++.(try first using array)

    Refer a good book in case of sudying data structure.
    Sorry i could give u more on it but sorry i am very busy now!!!
    For more info on C/C++ ask freely at
    anirban_ghosh@icqmail.com

  3. #3
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,399
    The internet holds a wonderful amount of information: http://www.google.com/search?q=stack%20data%20structure

    Look at that! The very first link is straight from wikipedia, and the second link points at a tutorial on cprogramming.com! Who would have thought that we'd have tutorials?
    If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

  4. #4
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    what are stacks?
    Stack of cards, stack of plates.
    For what are they good?
    Storing stuff.

    when should i use them
    When you want to retrieve items in the reverse order in which they were stored, i.e. you want to retrieve the last item you stored first, and the first item you stored last.

    and how are they implemented?
    The STL uses a deque.

  5. #5
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,794
    Quote Originally Posted by 7stud
    The STL uses a deque.
    By default... you can change it to something else if you want.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. stack and pointer problem
    By ramaadhitia in forum C Programming
    Replies: 2
    Last Post: 09-11-2006, 11:41 PM
  2. infix evaluation using stack
    By lewissi in forum C++ Programming
    Replies: 0
    Last Post: 11-03-2005, 01:56 AM
  3. Question about a stack using array of pointers
    By Ricochet in forum C++ Programming
    Replies: 6
    Last Post: 11-17-2003, 09:12 PM
  4. error trying to compile stack program
    By KristTlove in forum C++ Programming
    Replies: 2
    Last Post: 11-03-2003, 05:27 PM
  5. Stack Program Here
    By Troll_King in forum C Programming
    Replies: 7
    Last Post: 10-15-2001, 05:36 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21