Introduction to stacks

what is a stack?

the stack is one type of linear data structure. the elements in the stack are removed or ca be added only through one end, so stacks are called as LIFO (Last-In-First-Out) data structure, the element which is inserted at the last, that element can be deleted first

let’s look into the real world example

in the above examples, there are a stack of chairs, the user first inserted yellow chair and last chair will be brown, if the user wants to remove the orange chair, first brown and then the blue chair should be removed, user cant removed any middle chair without removing its above chairs

Applications of stacks

  • UNDO and REDO
  • Backtracking
  • Memory management
  • Expression Conversion like prefix, postfix, infix
  • Parsing

stacks visual in data structures

introduction to stacks
Last updated on by vishal devxo