-
-
Notifications
You must be signed in to change notification settings - Fork 359
Added Matlab bubblesort #166
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
Added Matlab bubblesort #166
Conversation
Looks good to me! Thanks :) |
And another matlab script... sorry that they didn't come simultaneously |
Ah, terrible timing, I already approved the merge without noticing your commit. |
retval = true; | ||
end | ||
|
||
function sorted_array = bogoe_sort(array) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bogoe?
disp(array) | ||
end | ||
|
||
function retval = is_sorted(array) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issorted()
is built-in, maybe use that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah know about this, but since we're teaching algorithms, it might be counterproductive to outsource too much to built-in methods. At the extreme case, you even have the sort()
-function in matlab, but I don't think it would be advisable to use that one here. We just have to use individual discression in each case and for this particular case I opted to use the build-in function randperm
, but not issorted
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I'm not going to insist on this one, your position is valid. It's just that, to me, the strength of matlab is the myriad of super useful built-in math functions that make your life easy. But you get it, you used randperm
and I love that you implemented the shuffle that way!
is_sorted
is a debatable, but using sort()
would obviously defeat the purpose of implementing bubble sort :)
Are you ready to merge or are you going to snipe-commit me again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ready for merging. Promise I want do any more sniping ;)
Yeah, you should probably not add more stuff after the fact. Next time, just open another PR. Smaller PRs are easier to review anyway. |
Inspired by #158, I decided to increase coverage for matlab