08 Queue and its applications
Updated 4 Oct 2026


- A queue is another special type of list, where the elements are
- Inserted only at the rear of the list
- Deleted only at the front of the list
- Queue is often called FIFO (First-In First-Out) structure
Queue Operations
enqueue: Insert an element at the rear of the queue
- Returns
true if the operation was successful.
dequeue: Remove the element at the front of the queue and return it.
queueFront get the value at the front of the queue
queueRear get the value at the rear of the queue
Application of Queues
- Prefix expression evaluation
- Round Robin scheduling
Prefix Expression
- Expression that the operator comes before two operands
Ex. + 5 6
– * 4 3 + 1 1
- Prefix Expression is parenthesis-free
- เลื่อนอันข้างไปหลัง Queue เรื่อย ๆ จนกว่า 3 อันข้างหน้าจะได้เป็น (1) Operator (2,3) Operand
- สุดท้ายจะได้เลขออกมา 1 ตัว
Round Robin Scheduler
- A round-robin scheduler is used to fairly allocate a limited resource that must be shared with a larger demand of users.
- It gives each process a unit of time, then moves to the next process, continues until all processes completed