NAME: Midterm Exam |
COS 226 Solutions, Spring 2011 |
A. E E A E Y R Q U E L K V Y S T O P S I T 4 exchanges B. c. To avoid quadratic running time. C. A E E E E Q U Y L K R Y S T O P S I T V 16 exchanges
A. N² B. log ( y / x) - Note: this is log base 10.
sorted order | reverse order | |
Quicksort | linearithmic | linearithmic |
Heapsort | linearithmic | linearithmic |
Insertion sort | linear | quadratic |
Selection sort | quadratic | quadratic |
Shellsort | linearithmic |
best case | worst case | |
BST | log N | N |
Heap-ordered complete tree | log N | log N |
Left-leaning red-black tree | log N | log N |
quick-union with path compression | 1 | N |
weighted quick-union | 1 | log N |
0 5
3 7 2 8 6 1 5
N C T I O B A D F U 0 1 2 3 4 5 6 7 8 9 10
D E A G B C F
if (a[k] - min > max) max = a[k] - min if (a[k] < min) min = a[k]
quadratic linear