Sorting a list of names lexographically

Say you are given a list of names, S = {s1, s2 ... sn} and you want to sort them lexicographically.

How would you guarantee that the running time of the sort is O(the total sum of the lengths of all the words)?

Any useful techniques?


One simple solution would be to use MSD radix sort, assuming a constant-size alphabet. Replace "digit" by "character" while reading the algorithm description. You will also need to throw out strings that are smaller than i if you are currently processing the position i, otherwise you won't get the desired runtime.

Need Your Help

commands at ubuntu shutdown

linux ubuntu-10.04

How to execute one or more commands and scripts when ubuntu shutdown? Is there any script like /etc/profile and ~/.bashrc at system starting?

Why do certain redirects cause Nexus Chrome browser to not run Javascript?

javascript android google-chrome redirect

On the Chrome 18.0.1025469 browser for Nexus 7, 4.2.2. certain redirects seem to cause Javascript not to load.