5.1 Linear Time Sorting Flashcards

1
Q

What is the number of permutations of n objects

A

n!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the height of binary tree with l leaves

A

at least log(L)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the height of a decision tree

A

at least log(n!)

which is actually

at least log((n/2)^n/2)

which is actually

nLog(n)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the lower bound for all comparison based sorting algorithms (run time complexity)

A

nLog(n)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What variables are needed for CountingSort?

A

A - input array
Z - output array
C - work array (where we count)
k - limit of the universe: {0, … ,k}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Is CountingSort in situ?

A

No

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Is countingSort stable

A

Yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the runtime complexity for CountingSort and what are the condition

A

O(n + k) when sorting numbers {0, … ,k} we have to set the restriction k

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is radixSort?

A

Uses counting sort but goes digit by digit

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the runtime complexity for Radixsort and what are the condition

A

O(s * (n+b)) where b = n + k in CountingSort and s is how many digit the numbers are

How well did you know this?
1
Not at all
2
3
4
5
Perfectly