Skip to content
Official PYQ · 1999

GATE CS 1999 Q1.12 — Searching, Sorting, Hashing

Explain with AI

A sorting technique is called stable if

Choose one option
View worked solution

Answer: B

A sorting algorithm is defined as stable if it preserves the relative order of equal (non-distinct) elements in the sorted output as they appeared in the original input.

Formally, if two items AiA_i and AjA_j have the same key value (i.e., key(Ai)=key(Aj)key(A_i) = key(A_j)) and AiA_i appears before AjA_j in the input list, then AiA_i will also appear before AjA_j in the sorted list.

  • Option A: Stability is independent of time complexity. For example, Merge Sort is stable and takes O(nlog⁡n)O(n \log n) time, while Heap Sort is unstable but also takes O(nlog⁡n)O(n \log n) time.
  • Option B: This is the exact definition of stability.
  • Option C: Stability is independent of the design paradigm. Merge Sort (divide-and-conquer) is stable, whereas Quick Sort (also divide-and-conquer) is typically unstable.
  • Option D: Stability is independent of space complexity.

Therefore, the correct option is B.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Searching, Sorting, Hashing questions