Skip to content

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

Merged

Conversation

VikingScientist
Copy link
Contributor

Inspired by #158, I decided to increase coverage for matlab

@jiegillet jiegillet added the Implementation This provides an implementation for an algorithm. (Code and maybe md files are edited.) label Jun 29, 2018
@jiegillet
Copy link
Member

Looks good to me! Thanks :)

@VikingScientist
Copy link
Contributor Author

And another matlab script... sorry that they didn't come simultaneously

@jiegillet
Copy link
Member

Ah, terrible timing, I already approved the merge without noticing your commit.
Next time, either do one chapter per PR or tell us to wait! Let me look at bogo sort...

retval = true;
end

function sorted_array = bogoe_sort(array)
Copy link
Member

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)
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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?

Copy link
Contributor Author

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 ;)

@Butt4cak3
Copy link
Contributor

Yeah, you should probably not add more stuff after the fact. Next time, just open another PR. Smaller PRs are easier to review anyway.

@Butt4cak3 Butt4cak3 mentioned this pull request Jun 29, 2018
@jiegillet jiegillet merged commit b5af512 into algorithm-archivists:master Jun 29, 2018
@VikingScientist VikingScientist deleted the MatlabBubbleSort branch June 29, 2018 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Implementation This provides an implementation for an algorithm. (Code and maybe md files are edited.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants