Re: QuickSort (worst-cases... special data)
- From: trt@xxxxxxxxxxxxxxxxxxxx (Tom Truscott)
- Date: Mon, 5 May 2008 20:48:26 +0000 (UTC)
I've got a problem with QuickSort's analysis.
The worst-case complexity is O(n^2) and in my analys I have data
generated in that way...
I think it is called A-shape and Vshape sequences...
The worst-case sequence depends on how quicksort selects the pivot.
If it uses median-of-1st,last,middle then both A and V should be equally bad.
Some quicksorts use the median of e.g. 9 elements, or choose "randomly".
That is still worst-case O(N^2) but not for the simple A and V patterns.
There is a worst-case O(N) median algorithm,
and a quicksort that uses it can be worst-case O(NlgN).
Tom Truscott
.
- Follow-Ups:
- References:
- QuickSort (worst-cases... special data)
- From: Sem
- QuickSort (worst-cases... special data)
- Prev by Date: QuickSort (worst-cases... special data)
- Next by Date: Re: QuickSort (worst-cases... special data)
- Previous by thread: QuickSort (worst-cases... special data)
- Next by thread: Re: QuickSort (worst-cases... special data)
- Index(es):
Relevant Pages
|