QuickSort: Partition

advertisement
QuickSort: Implementing The Partition Function
The goal for this exercise is to implement part of the QuickSort sorting algorithm –
the partition function.
Based on your personal research on the QuickSort algorithm, as well as the inclass preview, you should implement the Partition function (which is part of the overall
QuickSort sorting algorithm).
You should do this by implementing the Partition method on your
SearchingAndSorting class. This method takes three parameters:
1. an array of integers
2. A lower boundary (the left-most boundary)
3. An upper boundary (the right-most boundary)
This method should choose the first element in the array as the pivot (as
covered in the lecture), then it should partition the array as described in the lecture.
The method should then return the index of the pivot back to the caller
What you need to do for this exercise:
1. In the provided starter solution, in the PCE_ForTests project, you should find a
class named SortingAndSearching. You should implement Partition, as described
above.
2. Once you’ve done this, all the tests in the Test_Partition class should pass.
Download