Stack

  • It is an abstract data type
  • It is a linear ordered collection of similar data type.
  • It is based on LIFO(Last In First Out) principle
  • Insertion and Deletion are performed at same end
  • It can be implemented using both array and linked list.
  • A TOP pointer is used to pointer the topmost element of the element.

OVERFLOW : Overflow condition arises when stack is full and element is pushed on it. Condition for Overflow is : TOP=Max

UNDERFLOW : Underflow condition arises when stack is empty and element is popped from the stack. Condition for underflow is : TOP=-1

ALGORITHM : For array implementation

PUSH Operation : 

Insertion in stack

POP Operation :

Deletion in stack

C SOURCE CODE (Stack using Array)


For Linked List implementation :

Stack

PUSH :

Insertion in Stack - Step 1

(1)

Insertion in Stack - Step 2

(2)

Insertion in Stack - Step 3

(3)

POP

Deletionin Stack - Step 1

(1)

Deletion in Stack - Step 2

(2)

Deletion in Stack - Step 3

(3)

C SOURCE CODE (Stack using Linked List)

Leave a Reply

Your email address will not be published. Required fields are marked *