Sorting in linear time and in place
问题 Suppose that n records have keys in the range from 1 to k. Write an algorithm to sort the records in place in O(n+k) time. You may use O(k) storage outside the input array. Is your algorithm stable? if we use counting sort to we can do it in O(n+k) time and is stable but its not in place. if k=2 it can be done in place but its not stable (using two variables to maintain the indexes in the array for k=0 and k=1) but for k>2 i couldnt think of any good algo 回答1: First, let's rehash how counting