sorting Flashcards
insertion sort facts
best O(n)
average and worst O(n^2)
stable
in place
selection sort facts
O(n^2) across the board
not stable
in place
heapsort facts
O(n log n) across the board
not stable
in place
merge sort facts
O(n log n) across the board
stable
not in place
quick sort facts
the one that uses a pivot point and recursion/subarrays
best and average O(n log n)
worst case O(n^2)
not stable
in place
stable sorting
If a sort guarantees the relative order of equal items stays the same,
then it is a stable sort
In Place Sorting
Sorting of a data structure does not require any external data
structure for storing the intermediate steps
The amount of extra space required to sort the data is constant with
the input size.
bucket sort facts
O(n + k) across the board
n is the number of elements
k is the number of buckets
counting sort facts
O(n + k) across the board
n is the number of elements
k is range of elements
stable but not in place
radix sort facts
O(d * n) across the board
n is the number of items
d is the number of digit keys
not in place