-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Selection Sort in Lab9 doesn't work #129
Comments
Hi Zach - I do not see this problem. I tried it on all of the arrays included in a1 and it seems to sort them all fine: Selection sort: [ 3, 4, 5, 6, 8, 9 ] Could you give me an example of an input that causes this problem so I can reproduce? |
Ohhh, I see what's happening. I was calling the selection sort method on the array. In the selection sort method there is a printArray call to print out the array. This call is before the for loops execute so it will not show the last modification to the array, because it occurs after the printArray call. I was relying only on that printout and not printing the array again after completing the sort, so I never saw that the last swap was made, my mistake. |
Yes, that was just a debug print statement so people could see how the sort was working. You're right, though, it's kind of confusing. I'll remove it for next term (leaving this issue open until I get around to it). Thanks for noticing! |
The given selection sort function in the lab9 helper file doesn't seem to work. It sorts everything except for the last element [or 2, depending on how you look at it]. The problem is in the bounds of the for loops.
The text was updated successfully, but these errors were encountered: