Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

README.md

About Stack

What is a Stack ?

  • stack is one-ended linear data structure which models a real world stack by having two primary operations, namely Push and Pop . and named Last In First Out

Instructions

  • Explanation in an hour : ( 1:00:27 ) .

/icons/light-bulb_gray.svg

pop( ); // remove the first element in the data

push( “Onion” ); // add in the first element in the data

push( “Celery” )

push( “Watermelon”)

pop( )

pop( )

push( “Lettuce” )

When and Where is a Stack used ?

  • Used by undo mechanisms in text editors.
  • Used in compiler syntax checking for matching brackets and braces.
  • Can be used to model a pile of books or plates.
  • Used behind the scenes to support recursion by keeping track of previous functions calls.
  • Can be used to do a Depth First Search ( DFS ) on a graph.

Complexity Analyses

Pushing O( 1 )
Popping O( 1 )
Peeking O( 1 )
Searching O( n )
Size O( 1 )

Tower Of Hanoi

/icons/light-bulb_gray.svg

Explanation in a hour : ( 1:08:04 )