Question: Which of the following operations is used to just return the first element of a queue?
A Enqueue
B Dequeue
C Peek
D Push
Answer: Peek
Name of operation | Description | Example |
Peek | Returns the element at the front of the queue without removing it. | Checking who is at the front of the queue without serving or removing them. |
Enqueue | Adds an element to the back (end) of the queue. | Enqueueing a customer in a line: adding them to the end of the queue. |
Dequeue | Removes and returns the element at the front of the queue. | Dequeueing a customer from a line: serving the customer at the front of the queue and removing them. |
Push | It adds an element to the top (or end) of a stack. | Pushing a book onto a stack |