Skip to content

Computer Science · Ch 4 — Queue

Summary

Summary

  • A queue is an ordered linear data structure that follows the FIFO (First In, First Out) strategy: the element added first is removed first.
  • Front and Rear are the two ends of a queue — Front marks its beginning (where deletion happens) and Rear marks its end (where insertion happens).
  • In Python, a queue is implemented using the list type, and Python's predefined list methods take care of managing the Front and Rear ends for you.
  • Insertion in a queue always happens at the rear end; deletion always happens at the front end.
  • The insertion operation on a queue is known as enqueue, and the deletion operation is known as dequeue.
  • To support enqueue and dequeue, the supporting operations isEmpty, isFull, and peek are used.
  • A deque is a version of queue that allows insertion and deletion at both ends, not just one. …