Abstract


  • Linear, basically Array or Linked List with limitation that we can only push new element in from the back and remove elements from the front, follow a first-in, first-out (FIFO) principle.

Time Complexity

  • O(1) to offer() - push in an element
  • O(1) to poll() - pop out an element
  • O(1) to peek() - read the element that is the first to be pop out

Implementation


Implementation with Circular Array

Implementation with Single Linked List

  • Visual
  • push() from tail node
  • pop() & peek() from the head node

Questions