| | |
Summary: Written 6 Page 1
CS 2420 Fall 2010
Written 6 10 Points **Due at Classtime** \ Late assignments are NOT accepted
1. Timsort implements merging to minimize the amount of extra space required. For the
example below, write the code to do the merge and minimize auxiliary storage.
4 6 11 13 19 22 25 27 31 35 1 3 7 8 45
left mid right
2. With quicksort, show what happens after the call to partition using the data below. Use
the following algorithm for partition
int partition(int list[], int left, int right)
{ k = (left+right)/2;
swap(&list[left],&list[k]); // move pivot to left location
key = list[left];
i = left+1;
j = right;
while(i <= j)
{ while((i <= right) && (list[i] <= key))
i++;
while((j >= left) && (list[j] > key))
j--;
|