Given a list of strings each of length . What will be the worst case running time of sorting the strings in lexicographic order using merge-sort algorithm?
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Merge Sort needs O ( n l g n ) comparisons to sort n objects. To compare two strings of length n in lexicographic order, we compare the characters one-by-one until one where both are different. The worst case of this is O ( n ) where every characters are the same. Hence, O ( n l g n ) comparisons and each comparisons need O ( n ) , the answer is O ( n 2 l g n ) .