A queue is implemented using an array such that ENQUEUE and DEQUEUE operations are performed efficiently. Which one of the following statements is CORRECT (n refers to the number of items in the queue)?

This question was previously asked in

GATE CS 2016 Official Paper: Shift 1

- Both operations can be performed in O(1) time
- At most one operation can be performed in O(1) time but the worst case time for the other operation will be Ω(n)
- The worst-case time complexity for both operations will be Ω(n)
- Worst case time complexity for both operations will be Ω (log n)

Option 1 : Both operations can be performed in O(1) time

Free

ST 1: General Knowledge

5609

20 Questions
20 Marks
20 Mins

When we consider a normal implementation of the queue using an array, in that case for enqueue and dequeue operation, we have to shift every other element. In this, every time we remove the item from the start of the queue, all of the rest of the items in the queue move down by one to fill the space made by the removal of other items.

But if we consider the circular array implementation of a queue, in this case, both enqueue and dequeue can be performed in O(1) time.

**Diagram**

India’s **#1 Learning** Platform

Start Complete Exam Preparation

Daily Live MasterClasses

Practice Question Bank

Mock Tests & Quizzes

Trusted by 2,17,52,132+ Students

Start your FREE coaching now >>

Testbook Edu Solutions Pvt. Ltd.

1st & 2nd Floor, Zion Building,

Plot No. 273, Sector 10, Kharghar,

Navi Mumbai - 410210

[email protected]
Plot No. 273, Sector 10, Kharghar,

Navi Mumbai - 410210

Toll Free:1800 833 0800

Office Hours: 10 AM to 7 PM (all 7 days)