[fpc-devel] TStringList.CustomSort

Micha Nelissen micha at neli.hopto.org
Tue Nov 7 10:34:28 CET 2006


Vinzent Hoefler wrote:
>> It doesn't matter in O-time: both are O(n log n). Nevertheless, you
>> probably will save some function call overhead.
> 
> That highly depends on the sorting algorithm used. A plain Quicksort has 
> a very bad worst case of O(n**2) that develops especially when the list 
> to be sorted already is. Even Bubblesort would be faster in such a 
> case.

True, but I was too quick. Inserting in a list is O(n) of course, so 
it's O(n^2) for Add-Find-Insert case.

Micha



More information about the fpc-devel mailing list