Question 6 of 9intermediate🔍 AnalyzeShort Answer3 marks

How is queue data type different from deque data type?

Correct Answer

A queue is a linear data structure that follows the FIFO (First-In-First-Out) principle. In a queue, insertion happens only at the rear end and deletion happens only at the front end. The insertion operation is called enqueue and deletion is called dequeue.

A deque (Double ended queue) is a version of queue that allows insertion and deletion at both ends—head/front or tail/rear. It does not apply any restriction on the side from which elements should be added or removed.

The key difference is that a queue has restricted access (FIFO), while a deque provides flexibility to operate from both ends. Due to this, a deque can support both stack and queue operations.

Exercise: EXERCISE | Q: 5 | (Page 13)
For More Understanding

Explanation

The answer correctly identifies that queue follows FIFO with insertion at rear and deletion at front, while deque allows operations at both ends. The context clearly states these differences in sections 4.1 and 4.4. The operations listed (enqueue/dequeue for queue vs insertfront, insertrear, deletefront, deleterear for deque) further highlight the distinction.