reading-notes2

https://m7madmomani2.github.io/reading-notes2

View the Project on GitHub M7madMomani2/reading-notes2

Stacks and Queues

A stack is a data structure that consists of Nodes. Each Node references the next Node in the stack, but does not reference its previous.

Image

terminology for a stack:

  • Push Nodes or items that are put into the stack are pushed
  • Pop Nodes or items that are removed from the stack are popped. When you attempt to pop an empty stack an exception will be raised.
  • Top This is the top of the stack.
  • Peek When you peek you will view the value of the top Node in the stack. When you attempt to peek an empty stack an exception will be raised.
  • IsEmpty returns true when stack is empty otherwise returns false.

Stacks follow these concepts:

Image

FILO ===> First In Last Out ===> First Item added to all Last to Pop

LIFO ===> Last In First Out ===> Last Item added First to pop