CPSC 220
Fall 2005
HW 5: Mergesort
Consider the code for mergeSort on p. 355-356 of L&C.
- Trace this method for data=[5,1,7,3,4,6,2]. Show the following:
- The parameters for all recursive calls
- A detailed trace of the for loop for the top-level call
(min=0,max=6) and for each of the calls immediately below it. You do
not need to trace this loop for the rest of the calls.
- In clear, complete sentences, explain the role of each of the
following variables. Assume that you are speaking to an intelligent
freshman who has a general understanding of the mergesort algorithm but
is having trouble understanding the code.
- min
- max
- pivot
- index1
- left
- right
- temp