GateAI
Searching, Sorting and Hashing

GATE CSE 2016 Set 2 · Q13

MCQ1 markMedium

Time

Assume that the algorithms considered here sort the input sequences in ascending order. If the input is already in ascending order, which of the following are TRUE? I. Quicksort runs in Θ(n2)\Theta(n^2) time II. Bubblesort runs in Θ(n2)\Theta(n^2) time III. Mergesort runs in Θ(n)\Theta(n) time IV. Insertion sort runs in Θ(n)\Theta(n) time

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: D) I and IV only

Searching, Sorting and Hashing

Let us analyze the time complexity of each sorting algorithm when the input array of size nn is already sorted in ascending order:

  • I. Quicksort: Standard Quicksort (choosing the first or last element as the pivot) produces the most unbalanced partitions (subproblems of size 00 and n−1n-1), resulting in its worst-case recurrence T(n)=T(n−1)+Θ(n)=Θ(n2)T(n) = T(n-1) + \Theta(n) = \Theta(n^2). Hence, statement I is TRUE.

  • II. Bubblesort: An optimized version of Bubblesort with an early-exit flag checks if any swap occurred and terminates in Θ(n)\Theta(n) time on already sorted data. Hence, statement II is FALSE.

  • III. Mergesort: Mergesort always divides the array into two halves and recursively merges them, running in Θ(nlog⁡n)\Theta(n \log n) time in all cases (best, average, worst). Hence, statement III is FALSE.

  • IV. Insertion sort: When the array is already sorted, each element requires only 11 comparison and 00 shifts to confirm its position, resulting in Θ(n)\Theta(n) best-case running time. Hence, statement IV is TRUE.

Therefore, statements I and IV only are TRUE, which corresponds to option (D).

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 Searching, Sorting and Hashing previous year question is Q13 of the GATE CSE 2016 Set 2 paper. Find more GATE CSE PYQs on Searching, Sorting and Hashing 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 Searching, Sorting and Hashing 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.

Searching, Sorting and Hashing in GATE CSE

Searching, Sorting and Hashing has 27 GATE CSE PYQs across 20 papers from 2012 to 2026. 9 of them are 1-mark MCQs like this one, and it is the only one in GATE CSE 2016 Set 2.

How GATE tests Searching, Sorting and Hashing

More from GATE CSE 2016 Set 2

Share this solution

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

GateAI solution cardGATE CSE 2016 Set 2 · Q13 · MCQ

Assume that the algorithms considered here sort the input sequences in ascending order. If the input is already in ascending order, which of the following are TRUE? I. Quicksort runs in (n2) time II. Bubblesort runs in (n2) time III. Mergesort runs in (n) time IV. Insertion sort runs in (n) time

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.