著名外企面试题一道,关于排序,英文题目,欢迎讨论。(100分)
In 1983 a hot topic was the new "genius" bubble-sort algorithm. To sort a long list or array, you just traversed it and compared items 2 and 2. If the smaller one was after the bigger one, you swapped them.
This traversal was repeated until the items were sorted (no swap happened). Nowadays, bubble-sort is never heard of.
• Explain why and when bubble-sort is an inefficient sorting algorithm.
• Implement another sorting algorithm you find to be efficient.
• Document your sorting algorithm, what does it do, how and why is it efficient? The objects to sort should be arbitrarily long strings of 8 bit ASCII characters. The input is an unsorted list of such strings.
Use C, C++, Java or any other language, which we might reasonably be expected to understand. We expect you to write the complete code, i.e. don't use pre-defined libraries or language implementations with built-in hash functions. Also, we expect you to write the code yourself, although using books etc, as aid is not by any means prohibited.