1(7 points)
Sort the array
| 3 | 7 | 6 | 5 | 1 | 4 | 8 | 2 |
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | index |
| 3 | 7 | 6 | 5 | 1 | 4 | 8 | 2 | original array |
2(6 points)
Write a recursive
function
int S(int A[], int size)that returns the sum of
A[0] + A[1] + A[2] + . . . + A[size - 1].
3(7 points) The idea of the partition in QuickSort is:
A. Run a subloop to increase I until a large element is found
B. Run a subloop to decrease J until a small element is found
C. If it happens that I ² J after steps A and B then:
Show the work of the partition function
on the array below.
a. M = b. X = c. Show the contents of the array after each swap d. What are the values of I and J when the partition is finished?
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | index |
| 3 | 7 | 6 | 5 | 1 | 4 | 8 | 2 | original array |
Last Updated: May 5, 1997 7:01 pm by