I am working on dual pivot quick sort I found here (page no-20 in slide)
Comparisons:
Yaroslavskiy needs = 1.9 n ln n on average.
Classic Quicksort needs = 2 n ln n comparisons!
Swaps:
Swaps for Yaroslavskiy’s algorithm = 0.6 n ln n
Swaps for classic Quicksort=0.3 n ln n
Results
Data type-----comp-------swap
int -------------591ns---------802ns
float-----------838ns----------873ns
double -------873ns----------1047ns
char ----------593ns-----------837ns
/* note :- above results in nanosecond and performed in java lang using intel core 2 duo */
if we combine the cost of swap and comparison than Classic Quicksort beats Yaroslavskiy Quicksort except in case of string where we use array of pointer to swap which require 88 nanosecond.Here Yaroslavskiy’s algorithm take advantage of 1.9 n ln n comparison because comparison is too much expensive compare to swap in case of string.
i want to know why java uses Yaroslavskiy Quicksort ? is main focus of inbuilt library sort are string what if it is not good on others data type?