Skip to content

Latest commit

 

History

History
49 lines (36 loc) · 1.45 KB

Stack.md

File metadata and controls

49 lines (36 loc) · 1.45 KB

slides available here

#STACK by Jose Torres @CoderPug

##Concepts

  • ADT Abstract Data Type
  • Flexible size ( don't have to pre allocate memory, just add as you go ) ( When implemented with linked lists )
  • LIFO scheme for insertion and deletion ( Last In First Out )

image

##Operations

  • Push(:object) - inserts element at top
  • Pop() - remove element at top
  • Auxiliary
    • top() - returns last element without removing it
    • size() - returns number of elements stored
    • isEmpty() - returns boolean

##Representation

  • When using Linked List is composed as :
    • Node: { data, next< Node > }
    • Stack: { pointerTop< Node > , func... }

##Complexity

  • Push : O(1)
  • Pop : O(1)
  • Top/Peek : O(1)

##Direct Applications

  • Page visited web history
  • Undo sequence in editor
  • HTML Tag matching
  • ...

##Problems

##Bibliography

I totally stole the images from HackerRank - https://www.hackerrank.com/topics/stacks