Saturday, 21 April 2012

Stacks and Queues


Stacks and Queues-
              The linear data structure such as an array or linear list allows us to insert and delete an element at any place, namely either at the beginning or at the end or in the middle of the linear list. It is possible that we need a data structure which takes operations on only one end i.e. either at the beginning or at the end of the list Stack and Queue two such types of data structure which take operation only at the ends or at the beginning of the list.
Stack:-
              A stack is a linear data structure. But in this data structure elements are added to and removed only from one end of the list i.e. top of the stack. Thus stack provides the information in the reverse of the entry order, so it is called the last-in-first-out (LIFO) list.

              The operation of removing an entry from a stack is called a pop operation. If the elements are added continuously to a stack, it grows at the top end. New items are pushed on the top of the stack.
                           Representation of stack after inserting element


                          Representation of stack after inserting element


1 comment: