Question

A list of nn strings, each of length nn, is sorted into lexicographic order using the merge-sort algorithm. The worst case running time of this computation is

Choose one option
Official answer and solution
Official answer
Marks to all
From
Official GATE 2012 answer key
Why the marks went to every candidate

Official GATE answer key awarded Marks to All for this question.

Solution

Multiply the number of comparison operations in Merge Sort by the character comparison cost between strings of length n.

  1. Standard merge sort on a list of nn elements makes at most O(nlog⁡n)O(n \log n) element comparisons in the worst case.

  2. Comparing two strings of length nn to establish lexicographic order takes O(n)O(n) character comparisons in the worst case (when they share a long common prefix).

  3. Multiplying the number of element comparisons by the time required per comparison gives:

Total running time=O(nlog⁡n)×O(n)=O(n2log⁡n)\text{Total running time} = O(n \log n) \times O(n) = O(n^2 \log n)
  1. Reason for Marks to All: Standard big-OO represents an asymptotic upper bound. Although Θ(n2log⁡n)\Theta(n^2 \log n) is the tight bound corresponding to option (B), differing conventions regarding whether nn in the options referred to string length or total input size prompted GATE to award Marks to All.
Final answer

Marks to All (Tight worst-case complexity is O(n^2 log n), Option B; full credit given to all candidates).

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2012 Computer Science and Information Technology (CS)
Question
39 of 65, printed as CS Q.39
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.