GATE CS 2013 · Asymptotic Analysis & Recurrences

MCQ · 2 marks · Problem PROG-DIVC-0192

Consider the following operation along with Enqueue and Dequeue operations on queues, where k is a global parameter.
 MultiDequeue(Q){
m = k
while (Q is not empty) and (m > 0) {
   Dequeue(Q)
   m = m - 1
   }
}
What is the worst case time complexity of a sequence of n queue operations on an initially empty queue?
  1. A
    \(\Theta (n)\)
  2. B
    \(\Theta (n+k)\)
  3. C
    \(\Theta (nk)\)
  4. D
    \(\Theta (n^{2})\)

Solve it on GATE DA practice →More Searching & Sorting Algorithms problems

Show the worked solutionOfficial GATE Answer Key: Option A.See full step-by-step discussion on GateOverflow: https://gateoverflow.in/61/gate2013-44

GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com