GateAI
Asymptotic Analysis

GATE CSE 2013 · Q44

MCQ2 marksMedium

Time

Consider the following operation along with Enqueue and Dequeue operations on queues, where kk 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 nn queue operations on an initially empty queue?

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: A) (n)

Asymptotic Analysis

We use aggregate (amortized) analysis to find the worst-case total time for a sequence of nn operations:

  1. In any sequence of nn operations starting from an empty queue, the operations can be Enqueue, Dequeue, or MultiDequeue.

  2. An element can be dequeued (either in standard Dequeue or inside MultiDequeue) at most once for each time it was enqueued.

  3. Since there are at most nn operations in total, at most nn elements can ever be enqueued into the queue.

  4. Consequently, the total number of element deletions across the entire sequence cannot exceed nn.

  5. Each operation takes O(1)O(1) time in overhead plus O(1)O(1) time per element dequeued.

  6. Therefore, the total time for all nn operations combined is bounded by O(n)O(n). Since each of the nn operations takes at least Ω(1)\Omega(1) time, the worst-case total time is Θ(n)\Theta(n).

Hence, the correct option is (A).

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

This Asymptotic Analysis previous year question is Q44 of the GATE CSE 2013 paper. Find more GATE CSE PYQs on Asymptotic Analysis in Algorithms, or browse all GATE CSE PYQs.

Free diagnostic

Where do you stand for GATE?

Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Asymptotic Analysis PYQs now with no account.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

Asymptotic Analysis in GATE CSE

Asymptotic Analysis has 31 GATE CSE PYQs across 19 papers from 2011 to 2026. 12 of them are 2-mark MCQs like this one, and GATE CSE 2013 has 3.

How GATE tests Asymptotic Analysis

More from GATE CSE 2013

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2013 · Q44 · MCQ

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?

Topic-wise GATE CS PYQs with verified steps

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.