Question:

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:

Show Hint

Combine the sorting algorithm complexity with the cost of comparisons for string-based sorting problems.
Updated On: Dec 29, 2024
  • O(n log n)
  • O(n^2 log n)
  • O(n^2 + log n)
  • O(n^2)
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is B

Solution and Explanation

- Merge sort operates in O(n log n) for n elements. - When sorting n strings of length n, each comparison between two strings takes O(n) due to the length of the strings. - Thus, the total time complexity becomes: O(n · n log n) = O(n2 log n).
Was this answer helpful?
0
0

Top Questions on Algorithm

View More Questions

Questions Asked in CUET PG exam

View More Questions