__QuickSort__

- somewhat trickier than MergeSort
- join is trivial
- all the action happens in split
- in QuickSort , split sorts the elements into bins
- all the list elements less than the given number is the 'pivot'
- all the list elements Greater than a given number
- all list elements equal to the pivot
- choose the pivot arbitrarily from one of the list elements

eg

493872

choose 4 as pivot

low - 3,2

high - 9,8,7

pivot - 4

concatenate the list in order

sort(low)

sort(pivot + high)

- pivot list is guaranteed to have at least one element(the pivot)
- i want both split lists to be smaller than the initial list

- low list is non empty
- split between low and pivot
- if low is empty but high is not
- split between pivot and high
- if both low and high are empty then split somewhere in middle of pivot

## No comments:

Post a Comment