Activity Sheet 9

Manager
name:
Recorder
name:
Speaker
name:

Section 5.2

  1. We will sort the letters in the word ALGORITHM by using quicksort. For simplicity, once we have 3 elements or less we simply sort them by inspection. So we will only focus on the steps that get us to that point.
    1. What pivot would the “median-of-three” method choose? Your first step will swap the pivot to the first element.
    2. Carry out Hoare’s partition algorithm. What does the array look like at the end of that? What is the returned index?
    3. Repeat the above two steps for any of the two parts of the partition that has more than 3 elements.