View Single Post
Old 03-09-2007, 02:08 PM   #42 (permalink)
QwertyManiac
Commander in Chief
 
QwertyManiac's Avatar
 
Join Date: Jul 2005
Posts: 6,658
Default Re: Post ur C/C++ Programs Here

Stack is a simple Last-In First-Out data structure .. Its like this:

|20|
|30|
|40|
----

To add an element to it, we can only push from top and not insert anywhere we like:

So after pushing 10 into the stack, it looks like:

|10| <-- (Pushed on top)
|20|
|30|
|40|
----

Similarly, as its a LIFO system, Popping the stack removes the top most element.

Thus, 10 would be removed on popping:

|20| --> |10| (Popped out and deleted)
|30|
|40|
----

Stack's best application would be the function call. Recursion takes place in stacks format. (And are thus usually avoided)

Read more
__________________
Harsh J
www.harshj.com
QwertyManiac is offline