4 ms·
I think the intuition behind your Stooge sort example is that for an array separated into three segments: A | B | C The first sort moves the largest elements
by nsomani 7y ago
I think the intuition behind your Stooge sort example is that for an array separated into three segments:
A | B | C
The first sort moves the largest elements of A and B into B. The second sort moves the largest elements of B and C (and therefore of A, B, and C) into C. And the final sort properly orders the elements within A and B.
- arh68 7y agoOk but what does your intuition say about the first step? > If the value at the start is larger than the value at the end, swap them. What if we skip that? Broken sort? Is that step necessary, and if so, what's the edge case? Why even mention it? I hope I don't seem combative, I just find my intuition doesn't quite cover this problem.