An example of Best Case Scenario for Quick Sort (Need someone to check if my answer is correct)

后端 未结 2 1021
孤独总比滥情好
孤独总比滥情好 2021-01-15 12:16

Using a list of 15 numbers, I need to give a list representing the best and worst case scenario. It says \"q.s. uses the first item in the list as the pivot item\". I\'m n

2条回答
  •  遥遥无期
    2021-01-15 13:07

    It looks correct to me. If you are using quicksort with first element as the pivot then you want the first element to be the middle value of the array. The ideal pivot has an even amount of elements on each side.

提交回复
热议问题