5.1 Linear Time Sorting Flashcards
What is the number of permutations of n objects
n!
What is the height of binary tree with l leaves
at least log(L)
What is the height of a decision tree
at least log(n!)
which is actually
at least log((n/2)^n/2)
which is actually
nLog(n)
What is the lower bound for all comparison based sorting algorithms (run time complexity)
nLog(n)
What variables are needed for CountingSort?
A - input array
Z - output array
C - work array (where we count)
k - limit of the universe: {0, … ,k}
Is CountingSort in situ?
No
Is countingSort stable
Yes
What is the runtime complexity for CountingSort and what are the condition
O(n + k) when sorting numbers {0, … ,k} we have to set the restriction k
What is radixSort?
Uses counting sort but goes digit by digit
What is the runtime complexity for Radixsort and what are the condition
O(s * (n+b)) where b = n + k in CountingSort and s is how many digit the numbers are