9.4Sorting293After the call to Split, all the items less than or equal to splitValare on theleft side of the list and all of those greater than splitValare on the right sideof the list.The two “halves” meet at splitPoint, the index of the last item that is lessthan or equal to splitVal. Note that we don’t know the value of splitPointuntil the splitting process is complete. We can then swap splitVal (list[first])with the value at list[splitPoint].Our recursive calls to Quicksortuse this index (splitPoint) to reduce the sizeof the problem in the general case.Quicksort(first, splitPoint–1)sorts the left “half” of the list.Quicksort(split-Point + 1, last)sorts the right “half” of the list. (The “halves” are not neces-sarily the same size.)splitValis already in its correct position inlist[splitPoint].What is the base case? When the segment being examined has only oneitem, we do not need to go on.
This is the end of the preview.
access the rest of the document.