Quick Sort

  • Divide the given array into two and sort each

  • Differences from merge sort

    1. While merge sort just divides into two parts, quick sort positions items smaller than the pivot item on the left and larger items on the right when dividing

    2. After each part is sorted, merge sort requires "merging" post-processing work, but quick sort does not require it.

  • Time complexity

    • nlogn

Hoare-Partition Algorithm

Idea

  • Position values larger than P(pivot) in the right set and smaller values in the left set

  • Position the pivot in the middle of the two sets

Pivot Selection

  • Left end / Right end / Middle value among three arbitrary values

Example)

Last updated