StreakPeaked· Practice

ExamsGATETechnical

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)?

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

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

Solution

Both ENQUEUE and DEQUEUE operations can be implemented to run in O(1) time by using a circular array approach, which allows efficient addition and removal of elements without needing to shift other elements.

Related GATE Technical questions

⚔️ Practice GATE Technical free + battle 1v1 →