Stack in C

Previous
Next

Stack:

  • Stack is a linear data structure.
  • Stack is an ordered list of similar data type.
  • Stack in which elements follow a specific order and operations will be performed.

Note: We create Stack using arrays, only the way of representation and Rules of accessing elements vary.

  • Stack follows LIFO(Last In First Out).
  • Elements will be added from the end called TOP of stack and removes from the same end.
ArrayStack
Linear data structureLinear data structure
Process elements using IndexProcess element using top
Insert element any whereInsert at top only
Delete element from any whereDelete from top
Display element in any formatDisplay elements in LIFO

Work flow:

Stack ADT: Abstract Data Type specifies the operations can be performed on Stack

  1. Push: Push an element on to the Stack. Returns “Overflow” if stack is full.
  2. Pop: Deletes top item from Stack. Returns “Underflow” if Stack is empty.
  3. Peek: Returns top element of stack but not removes.
  4. isEmpty: Returns true if stack is empty, else false
  5. isFull: Returns true if stack is full, else false
  6. Traverse: Display elements of Stack.
Previous
Next

Add Comment

Courses Enquiry Form