4 ms·
The time complexity looks very bad (assuming I can read shell, which I am not sure about). First it appears it has the classic bug of passing items equal to th
by jmount 12y ago
The time complexity looks very bad (assuming I can read shell, which I am not sure about).
First it appears it has the classic bug of passing items equal to the partition to sub-sorts (G in this case). This guarantees N recurses (and at least c N^2 operations) when trying to sort an array that is all duplicates of a single value. Also the list concatenations ( L="$L $i" and G="$G $i") which often make mere list assembly take c N^2 time (pretty much forced by the string representations). So this could be a c N^3 worst-case sorting algorithm (possibly worse than bubble sort).
One of my articles on the pain of quicksort: http://www.win-vector.com/blog/2008/04/sorting-in-anger/ http://www.win-vector.com/blog/2008/04/sorting-in-anger/
- wyc 12y agoHaha, there are few places where this submission would result in such a decent analysis. Thanks.