reading-notes

Stacks and Queues

Source: Stacks and Queues

Stacks

Stacks operate as LIFO (Last In First Out). All actions operate on the top of the queue.

  1. Push - Add top top of stack
  2. Pop - Remove from top of stack
  3. Top - Top of the stack
  4. Peek - Check the top value

stack example

Queues

Queues operate as FIFO (First In First Out). Items removed from front of queue, but added to end.

  1. Enqueue - Add to back of the queue
  2. Dequeue - Remove from front of the queue
  3. Front - Beginning of queue
  4. Rear - End of queue
  5. Peek - Check the front value

queue example