4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-01-19 12:59:21 +08:00
Hakan Lindqvist 0045445ad6 Ensure qsort recursion depth is bounded
The qsort algorithm splits the input array in three parts. The
left and right parts may need further sorting. One of them is
sorted by recursion, the other by iteration. This update ensures
that it is the smaller part that is chosen for recursion.

By choosing the smaller part, each recursion level will handle
less than half the array of the previous recursion level. Hence
the recursion depth is bounded to be less than log2(n) i.e. 1
level per significant bit in the array size n.

The update also includes code comments explaining the algorithm.
2018-03-16 10:21:23 +01:00
..
2002-06-20 19:51:40 +00:00
2018-01-17 11:47:26 -06:00
2002-06-20 19:51:40 +00:00
2018-01-17 11:47:26 -06:00
2017-12-07 11:54:11 +00:00
2002-06-20 19:51:40 +00:00
2017-12-01 03:41:51 -06:00
2018-01-17 11:47:26 -06:00
2018-01-17 11:47:26 -06:00
2018-01-17 11:47:26 -06:00
2002-06-20 19:51:40 +00:00
2018-01-17 11:47:26 -06:00
2018-01-17 11:47:26 -06:00