Intuitive explanation for why QuickSort is n log n?

后端 未结 6 1119
悲&欢浪女
悲&欢浪女 2020-12-07 09:23

Is anybody able to give a \'plain english\' intuitive, yet formal, explanation of what makes QuickSort n log n? From my understanding it has to make a pass over n items, and

6条回答
  •  时光取名叫无心
    2020-12-07 10:13

    In-fact you need to find the position of all the N elements(pivot),but the maximum number of comparisons is logN for each element (the first is N,second pivot N/2,3rd N/4..assuming pivot is the median element)

提交回复
热议问题