A list of n strings, each of length n, is sorted into lexicographic order using the merge-sort algorithm. The worst case running time of this computation is
Topic-wise GATE CS PYQs with verified steps
GATE CSE 2012 · Q39
Time
Select one answerSingle correct
Solution
Official answer: See verified solution
Searching, Sorting and HashingStandard merge-sort sorts a list of elements using comparisons.
In this problem, each element is a string of length . Comparing two strings of length takes time in the worst case.
Therefore, the worst-case time complexity of merge-sort on strings of length is:
*Note*: In the official answer key for Paper CS Code A, this question was awarded Marks to All (though in some codes it was marked as option B).
Try the question first, then check your work.
Examiner trap
Recall that merge sort makes comparisons, and each comparison between two strings of length takes worst-case time.
This Searching, Sorting and Hashing previous year question is Q39 of the GATE CSE 2012 paper. Find more GATE CSE PYQs on Searching, Sorting and Hashing in Algorithms, or browse all GATE CSE PYQs.
Free diagnostic
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.
An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.
Searching, Sorting and Hashing has 27 GATE CSE PYQs across 20 papers from 2012 to 2026. 7 of them are 2-mark MCQs like this one, and it is the only one in GATE CSE 2012.
How GATE tests Searching, Sorting and HashingIndependent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.