Worst case for QuickSort - when can it occur?

后端 未结 6 1003
北海茫月
北海茫月 2020-11-27 15:22

When analyzing QS, every one always refers to the \"almost sorted\" worst case. When can such a scenario occur with natural input?

The only example I came up with is

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-27 15:40

    worst case in quick sort:

    1. All elements of array are same
    2. Array is already sorted in same order
    3. Array is already sorted in reverse order.

提交回复
热议问题