Quicksort Pivot

前端 未结 5 1696
鱼传尺愫
鱼传尺愫 2021-01-12 06:36

Sort the following array a using quicksort,

[6, 11, 4, 9, 8, 2, 5, 8, 13, 7]

The pivot should be chosen as the arithmetic mean of the first

5条回答
  •  走了就别回头了
    2021-01-12 07:12

    The position of the pivot from that calculation is not important, quicksort sorts the elements based on whether they are more or less than the pivot. Then the pivot is placed in between the two sets (more and less).

提交回复
热议问题