Stack and its operations

Introduction to Data Structure
  • We can use data structure depending upon our areas of application.
  • A data structure can be simple or complex.
  • These kinds of data structures are known as Fundamentals data structure or Classic data structure.
  • There are two kinds of classic data structure.
    1. Linear.
    2. Non-Linear.
  • The Linear data structure can be categories as:
    1. Array
    2. Linked List
    3. Queue
    4. Stack
  • The non-linear data structure can be categories as:
    1. Files
    2. Tables
    3. Tree
    4. Graph

Stacks
  • Stack is a linear data structure.
  • It is very useful for various applications for computer science.
    • Example: Shunting train in railway yards
    • Example: Shipment in cargo 
    • Example: Plates on a tray
    • Example: Stacks of coins
    • Example: Stacks of drawers
  • The strategy to store and retrieve in stack data structure is LIFO.
  • LIFO stands for Last In First Out.
  • The stack data structure has the following kinds of characteristics:
    • It is an ordered collection.
    • It has homogeneous data elements.
    • It can insert or delete elements.
    • The insertion and deletion take place at one end only
  • The insertion operation in stack called a PUSH.
  • The deletion operation in stack called a POP. 
  • The PUSH & POP operations performed on the position of the stack are called TOP of the stack.
  • The elements of the stack are called an ITEM.
  • The maximum number of elements is considering as SIZE.
  • Sometimes, a stack may face two different kinds of errors.
  • Underflow: when POP operations performed and stack is empty.
SIZE = 5 and POP operations
  • Overflow: when PUSH operation performed and stack is a full.
SIZE = 5 & PUSH operations
Representation of STACK
  • You can implement STACK using any computer programming language.
  • We can implement STACK using various ways:
    • Using One Dimension array
    • Using Single Linked List
Operations on STACK
  • The basic operations on STACK are:
    • Push: It is used to insert a new item.
    • Pop: It is used to delete existing item
    • Peep or Peek: It is used to pick up existing items.
    • Change: It is used to change the existing items.

Thanks a lot for query or your valuable suggestions related to the topic.

Previous Post Next Post

Contact Form