Hi Everyone!
It appears that there were bugs in both of my implementations of Insertion Sort, where the program wouldn't always loop enough to sort some input. I have correct this by using nested for loops just like in Bubble Sort, which I should have done in the first place since Insertion Sort has O(n^2) complexity. Oops!
Thanks to JSchmoe for pointing this out. More sorting tutorials are coming, hopefully with all bugs "squashed" in time.
You can find the updated implementations on my pastebin page.
3 Responses
Don't you test your code before submitting them?
Of course, but it was passing my input. I didn't find an input that failed until just yesterday.
Bad testing. Tsk.
Share Your Thoughts