TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: Pascal Schmidt
from: Jasen Betts
date: 2004-05-23 08:49:16
subject: A question

Hi Pascal.

22-May-04 14:23:36, Pascal Schmidt wrote to Jasen Betts


 PS> Hi Jasen! :-)

 PS>>> Quicksort has a worst-case of O(n^2), in the case of an already
 PS>>> sorted array. But your right, on random data it's O(n log n)
 JB>> Most implementations of qsort() have code to handle that case
 JB>> better.

 PS> Hard to check for, I'd think.

typically what they do is sample the list at three points and that the
middle of the three as the pivot

this strategy works well on sorted data and also slightly improves
performance on random data.

it's still possible to order data such that it'll be hard to qsort
but the ordering required to do this is much more compleex than simple
sorted order, and much less likely to be encountered in real life.

 -=> Bye <=-

---
* Origin: Bushido does not mean what it sounds like. (3:640/1042)
SEEN-BY: 633/267 270
@PATH: 640/1042 531 954 774/605 123/500 106/2000 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.