Applications of Linked List (Part 1 Stack)

Applications Of Linked List

Part 1 Stack



As we learned about various types of linked list like Singly Linked List, Doubly Linked List, Circular Linked List and Multiply Linked List in the previous posts from now onwards we will apply these data structures into various applications which are used in real world. One of the example of implementation of the Singly Linked List is Stack.


Stack

Stack is First in Last out data structure. (FILO) , Imagine stack as a data structure which have closed entry or exit from the end. 






Stack is one of the important application of singly linked list. stack can be used in various applications, one of the use is in Push down Automata , Other real life scenarios can be Suppose we are organising an even to which we are selling tickets, to the first customer we want to give highest discount but it could only be redeemed at last to implement this problem we use concept of stack. the concept of stack can even be used in the tower of Hanoi game implementation, in this post we will be learning basics of how to program a stack using linked list.



Operations on stack:

Some of the Basic operations on stack are Push and Pop. 

  1. Push:- In Push operation, we push the element into the stack.
  2. Pop:- In Pop operation, we pop the topmost element outside the stack.
Aside from operations, some of the basic terminology used in stack are:- 
  1. Stack Overflow:- If we get past the capacity of the stack, then stack overflow takes place. stack overflow concept can be understood by thinking about a glass of water, When we fill it and it reaches the brim and we keep filling the water , stack overflow takes place.
  2. Stack Underflow:- If the stack becomes empty and we still keep trying to pop something out of it then stack underflow takes place. stack underflow can be thought as if there is a jar filled with coins, when we take out each and every coin of the jar, and we keep trying to take out coin from the empty jar, there is a stack underflow. 



Stack Cpp Program:


Popular Posts