The time complexity of counting sort
问题 I am taking an algorithms course and there I saw that the time complexity of counting sort is O(n+k) where k is the range of numbers and n is the input size. My question is, when the difference between k and n is too much, such as when k=O(n 2 )or O(n 3 ), can we say that the complexity is O(n 2 ) or O(n 3 )? Then in this case counting sort is not a wise approach and we can use merge sort. Am I right? 回答1: Yes, you are exactly right on all counts. Furthermore, we can make stronger statements: