next up previous
Next: About this document ... Up: Assignment 12: Arrays of Previous: Shuffling and sorting

Merge

1.
Type in the subdeck method from the alternate version of Chapter 13, and test it.

2.
Using the pseudocode in Chapter 13, write the method called merge.

3.
Write the simple version of mergeSort, the one that divides the deck in half and then uses sortDeck to sort the two halves. Then it uses merge to create a new, fully-sorted deck.

Note that in previous assignments when we ``broke'' arrays in half, we just used index ranges to specify the halves. We didn't actually create halves. For mergeSort we actually create new decks and subdecks using subdeck and merge.

4.
Write the fully recursive version of mergeSort.



Allen B. Downey
1999-04-28