1 |
h10 |
CS32 W19 |
Name: | ||||
---|---|---|---|---|
(as it would appear on official course roster) | ||||
Umail address: | @umail.ucsb.edu | section 1pm, 2pm, 3pm, 4pm |
||
Optional: name you wish to be called if different from name above. | ||||
Optional: name of "homework buddy" (leaving this blank signifies "I worked alone" |
h10: Mergesort and Quicksort
ready? | assigned | due | points |
---|---|---|---|
true | Mon 02/04 09:30AM | Mon 02/11 09:30AM |
You may collaborate on this homework with AT MOST one person, an optional "homework buddy".
MAY ONLY BE TURNED IN IN THE LECTURE LISTED ABOVE AS THE DUE DATE,
OR IF APPLICABLE, SUBMITTED ON GRADESCOPE. There is NO MAKEUP for missed assignments;
in place of that, we drop the lowest scores (if you have zeros, those are the lowest scores.)
Reading: Mergesort and Quicksort, DS 13.2
- (10 pts) Fill in the information in the header. The following are required to get the 10 "participation" points.
- Filling in your name and umail address.
Also: For paper submission PLEASE submit on ONE SHEET OF PAPER, double-sided if at all possible. If you must submit on two printed sheets write name on BOTH sheets and no staples, paperclips, or folded corners.
- Filling in your name and umail address.
- Circle the big-O worst-case running time for sorting an array of n elements, using these algorithms:
- (3 pts) Mergesort O(1) O(log n) O(n) O(n log n) O(n2) O(n2 log n) O(n3)
- (3 pts) Quicksort O(1) O(log n) O(n) O(n log n) O(n2) O(n2 log n) O(n3)
- Circle the big-O average case ("expected case") running time for sorting an array of n elements, using these algorithms:
- (3 pts) Mergesort O(1) O(log n) O(n) O(n log n) O(n2) O(n2 log n) O(n3)
- (3 pts) Quicksort O(1) O(log n) O(n) O(n log n) O(n2) O(n2 log n) O(n3)
- Both Mergesort and Quicksort are divide-and-conquer algorithms.
- (6 pts) What is the main idea behind divide-and-conquer?
- (5 pts) Describe briely how the divide-and-conquer idea, as you explained in part (a), applies to Mergesort.
- (5 pts) Describe briely how the divide-and-conquer idea, as you explained in part (a), applies to Quicksort.
- (6 pts) Given that the way divide-and-conquer applies to Mergesort and Quicksort is similiar, briefly highlight the difference(s) between Mergesort and Quicksort.
- (6 pts) Briefly describe the role of the pivot element in Quicksort.