-
Notifications
You must be signed in to change notification settings - Fork 1
Sorting in linear time
-
each of the
n
input elements is an integer in the range between0
tok
-
k
is some integer that:k=O(n)
-
determine, for each input element
x
, the number of elements less than x -
place element
x
directly into its position in the output array
Notes: counting sort is stable
-
each of the
n
input elements hasd
digits, each digit is in the range between0
tok
-
d
is constant, andk=O(n)
from the lowest to highest order digit, use a stable sort (e.g. counting sort) to sort the array on that digit
-
sort dates by three keys: year, month, and day
-
sort
n
integers in the range0
ton^2-1
inO(n)
time (convert the input integers into n-based digits). Similarly, it can be extended to the range0
ton^k-1
, wherek
is a constant.
-
the input is generated by a random process that distributes elements uniformly
-
the input elements are real numbers in the range of
[0,1)
-
divide the elements into one of the
n
equal-sized buckets, so that A[i] is in the bucket indexed by floor(n*A[i]) -
sort elements in each bucket using some comparison sort (e.g. insertion sort)
-
concatenate the buckets from
1
ton
together in order