We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I think part of the problem people are having is how strict the output requirements are. For example, when sorting '2 3 4 5 1', my first draft would output '2 3 4 1 5' rather than the expected '2 3 4 5 5', because my first thoughts on implementing the algorithm was to breaking it down into atomic steps of -swapping- values.
I had to pretty much entirely rewrite it so it would conform to your expected out, despite the fact that it performed perfectly.
Insertion Sort - Part 1
You are viewing a single comment's thread. Return to all comments →
I think part of the problem people are having is how strict the output requirements are. For example, when sorting '2 3 4 5 1', my first draft would output '2 3 4 1 5' rather than the expected '2 3 4 5 5', because my first thoughts on implementing the algorithm was to breaking it down into atomic steps of -swapping- values.
I had to pretty much entirely rewrite it so it would conform to your expected out, despite the fact that it performed perfectly.