Wednesday, 11 July 2012

Stacks - Linear Data Structure


Introduction - 

          Stack is an ordered collection of data items. It is a last in, first out (LIFO) abstract data type and linear data structure. In stack new items can be added and removed only at the top. Stack is similar to a pile of dishes where dishes can be added at the top and dish coming last would be removed first.

Remark - So, stack is a linear data structure where items are added or removed at one end only.



      Figure - Stack


Operations on Stack - 

                There are basically two primitive operations that can be carried out on a stack -

Push - Push operation is used to add a new node to the top of the stack.

Figure -  Push operation on Stack


Pop - Pop operation is used to remove an existing node from the top of the stack. 

Figure - Pop operation on Stack



Uses of Stacks - 

  • Stacks are used for evaluating Arithmetic expressions (and other sorts of expression).
  • Generally used for implementing function or method calls.
  • Implementing Recursion.


No comments:

Post a Comment