GATE CS 2016 Set 2 — Question 23
Go beyond PYQs with Success TrackerAI-powered personalised practice and doubt support. Unlimited practice on eligible plans; AI usage limits apply.MCQ+1 / -0.33MediumQuick SortSortingAlgorithmsBubble, Insertion, Selection SortMerge SortBest, Worst, Average CaseAsymptotic Analysis
Algorithms → Asymptotic Analysis → Best, Worst, Average Case
Last updated
Question
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 time
II. Bubblesort runs in time
III. Mergesort runs in time
IV. Insertion sort runs in time
II. Bubblesort runs in time
III. Mergesort runs in time
IV. Insertion sort runs in time
Correct answer
(D) I and IV only
Solution
1.Quicksort: When the input is already sorted (ascending), and assuming the standard pivot selection (first or last element), the partition will be extremely unbalanced (one side has 0 elements, the other has ). This leads to a recurrence , which solves to . Thus, statement I is TRUE.
2.Bubblesort: The standard optimized Bubblesort (with a flag to detect if any swap occurred) will make one pass through the sorted array, perform no swaps, and terminate. This takes time. If the unoptimized version is considered, it takes . However, looking at the options, if II were true (unoptimized), then both I, II, and IV would be true, but there is no option for "I, II and IV". If II is false (optimized), then only I and IV are true, which matches option (D). Thus, we assume the optimized version. Statement II is FALSE.
3.Mergesort: Mergesort always divides the array into halves and merges them. Its recurrence is always , regardless of data order. The time complexity is . Thus, statement III is FALSE.
4.Insertion Sort: When the input is already sorted, the inner loop condition is never met (or met once and breaks immediately), resulting in work per element. The total time is . Thus, statement IV is TRUE.
Since I and IV are true, the correct option is (D).Continue learning with Success Tracker
A step still unclear? Work through it with support
Use Success Tracker to ask about the reasoning, then try another GATE CS question to check your understanding.
AI-powered practice· Unlimited practice on eligible plans
- PYQs with solutions
- Attempt available previous-year questions, then compare your reasoning with the worked solution. Coverage varies by stream.
- Practice that adapts
- Choose a topic, work on weaker areas and bookmark questions to revisit. Your attempts feed your progress tracking.
- AI doubt support
- Ask follow-up questions about a step or concept while practising, instead of stopping at the final answer.
Unlimited practice is available on eligible plans. Free practice and AI usage have limits; check the current plan allowances before choosing.
This page stays readable without an account. AI responses can be wrong; check them against the solution and source material.
More questions on Asymptotic Analysis
2026 Set 1 Q17Consider the following recurrence relations: For all ,…2026 Set 2 Q24Consider the following functions, where is a positive integer.…2026 Set 2 Q25Which of the following can be recurrence relation(s) corresponding to an algorithm with time…2026 Set 2 Q32Consider an array . Suppose the merge sort algorithm is…2026 Set 2 Q37Let be a weighted directed acyclic graph with edges and vertices. Given and a…