⬅ Previous Topic
Queues IntroductionNext Topic ⮕
Time Complexity of Queue Operations⬅ Previous Topic
Queues IntroductionNext Topic ⮕
Time Complexity of Queue OperationsQueues support a core set of operations that are fundamental to their First-In First-Out (FIFO) behavior. In this section, we explore the essential operations — Enqueue, Dequeue, Peek, isEmpty, Size, and Traversal — using visual step-by-step diagrams.
The enqueue operation adds a new element to the rear (end) of the queue.
Initial Queue
Enqueue 40 to the rear
Updated Queue
The dequeue operation removes the front element from the queue.
Initial Queue
Dequeue 10 from the front
Updated Queue
The peek operation returns the front element of the queue without removing it.
Current Queue:
Peek Result: 10
The isEmpty operation checks whether the queue has any elements.
isEmpty Result: false
isEmpty Result: true
The size operation returns the number of elements currently present in the queue.
Size Result: 3
Size Result: 0
⬅ Previous Topic
Queues IntroductionNext Topic ⮕
Time Complexity of Queue OperationsYou can support this website with a contribution of your choice.
When making a contribution, mention your name, and programguru.org in the message. Your name shall be displayed in the sponsors list.