Quick sort and quick selection are algorithms based on the partition algorithm. Partition algorithm makes a two sublist($\mathcal{A},\mathcal{B}$) and one value(pivot$ = \gamma$). Every element in $\mathcal{A}$ is less or equal than $\gamma$. Every element in $\mathcal{B}$ is greater than $\gamma$. Notice that $\mathcal{A}$ can have some elements which have the same value with $\gamma$ but not $\gamma$ itself and $\mathcal{A},\mathcal{B}$ may be $\emptyset$. As a result, partition function makes $\gamma$ is the highest value of $\mathcal{A}$. Quick sort uses this property to sort the list. After partition function, $\mathcal{A}$ and $\mathcal{B}$ is sorted to each other by $\gamma$. Therefore, quick sort just sort recursively in $\mathcal{A}$ and $\mathcal{B}$. Quick selection do the simillar thing. Quick selection is an algorithm to find a $n$th element in the entire list. If the order of $\gamma$ is equal with what you seek for, it’s done. If the order of $\gamma$ is less than what you seek for, adjust the order to find and try to check $\gamma$ in $\mathcal{B}$ again. If the order of $\gamma$ is greater than what you seek for, adjust the order to find and try to check $\gamma$ in $\mathcal{A}$ again. It works like semi-quick sort, it sorts a little bit and tries to find the elements in $n$th order and keep going on.
1 |
|