Here's our first data structure , which is called a stack . The most
important property of a stack , which makes it different from a
queue is that it's is "LIFO : Last input
first output " , this looks like placing some copybooks on your desk ,
and then when you want one of them (assume that they are all simillar )
you've to take the one on the top first which is the last one was placed.
Notes.
* Write an element in stack ... Push.
* Move an element from stack ... Pop.
* Read an element from stack without deleting ... Top.
* IsEmpty and IsFull functions are never used when
dynamically allocated stack "Linked Stack".
* The main difference between the stacks and arrays is
that arrays have direct access to any element in it.
Syntax.
< stack.h >
#include < iostream.h >
#include < stdlib.h >
#include < assert.h >
/* To use assertion in the programme */
(1)Reversing ... When you want to reverse a queue you've to use a
stack as one of them it "FIFO:Queue"
and the other is "LIFO:Stack"
(2)System control stack.