General Notes

Queue

  • A list operating on the First In First Out principle (FIFO)
  • The first item added is the first item to be removed
  • Data is added from the rear end by using the EndPointer/TailPointer and removed from the front by using the StartPointer/HeadPointer
  • Enqueue: Add an element to the back of the queue.
  • Dequeue: Remove the element at the front of the queue.
  • isEmpty: Check if the queue is empty.
  • Applications: Task Scheduling in OS and printer, Handling request in web server, streaming, call centers, handling packets, messaging or ordering services, video or mp3 players, traffic management, physical queues like supermarket

  • Linear Queue: Normal queue following simple FIFO queue; cannot reuse freed spaces
  • Circular Queue: Last position is connected back to the first position to form a circle, it reuses empty spaces in the list
  • Advantages: Large data managed efficiency, multi user services
  • Disadvantages: Operations on middle elements are hard, maximum size defined before implementation

Code for linear queue

PYTHON

Python can be executed directly in the browser.

Editor — Python
Output
No output yet.

Code for Circular Queue

PYTHON

Python can be executed directly in the browser.

Editor — Python
Output
No output yet.