what are stacks? For what are they good? when should i use them and how are they implemented?
Printable View
what are stacks? For what are they good? when should i use them and how are they implemented?
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
[email protected]
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?
Stack of cards, stack of plates.Quote:
what are stacks?
Storing stuff.Quote:
For what are they good?
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.Quote:
when should i use them
The STL uses a deque.Quote:
and how are they implemented?
By default... you can change it to something else if you want.Quote:
Originally Posted by 7stud