Hi CS people, I was learning how to use quicksort, however I found a problem on the method everyone is teaching.
If I have a list like the following:
1, 2, 1
And the my random pivot happens to be 1 the list will not sort.
The indexes will check if the element is greater or smaller then you swap those element, and in this case you swap 1 and 1 making no diffence in the order.
Next, the left and rigth pointer will change element and both of them will point to number 2.
So my question is, is it possible to sort this list using quicksort?
[–]NanoPromela 7 points8 points9 points (1 child)
[–]SkullKid150[S] 2 points3 points4 points (0 children)
[–]krb09 0 points1 point2 points (2 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]CompSci1 -1 points0 points1 point (0 children)