-
-
Notifications
You must be signed in to change notification settings - Fork 360
Added Processing language + BogoSort implementation #436
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
Conversation
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.
Not used to the processing language. I asked a few questions, also the randomize()
function seems a bit odd, but maybe I am just misreading it.
book.json
Outdated
@@ -139,6 +139,10 @@ | |||
{ | |||
"lang": "f90", | |||
"name": "Fortran90" | |||
}, | |||
{ | |||
"lang": "processing", |
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.
I think lang
should be the file extension, which is pde
in this case.
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.
Yes you are right, do I need to change that in the Pull request?
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.
@johhnry Yep. Just push your changes to the branch you made this PR from.
random_array(test_array,0,100); | ||
} | ||
|
||
void draw(){ |
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.
Dumb question about processing. Does everything require a visual output?
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.
It's not a requirement but Processing language was created for that kind of task.
I found it nice to visualize the sorting process.
return true; | ||
} | ||
|
||
void bogo_Sort(int[] 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.
It seems like we are mixing camel case and snake case here. We should probably choose one.
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.
Is it possible to change the code of a pull request?
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.
Just commit to the branch you have in your forked repo and the PR automatically updates. Read carefully the contributing tutorial!
I'm not sure if we need this. The algorithms themselves are almost just plain Java and everything this adds on top is the visualization code which doesn't really help to teach the algorithms. |
this is a small thing, but you have merge conflicts in book.json and bogo_sort.md You can also use frame.setVisible(false); in processing if you decide you don't want to have the drawing window and just print to the console. |
@Butt4cak3 |
I wrote some visualization before, it was in Elm in the Euler method chapter. We discussed a bunch, and I ended up displaying the parts relevant to the algorithm, then the full code after, along with a link to my GitHub.io with the interactive visualization. |
I don't think processing can run in gitbook, though? |
@leios |
I don't think we should go down the road of adding that to the AAA, but if you have a personal page, you should definitely set it up there and add a link |
Now we're getting back to the old discussion about interactive visualizations in the AAA, which we have turned down in the past (see HOVL). |
@Butt4cak3 |
I just saw that there's an animation in this page : https://www.algorithm-archive.org/contents/monte_carlo_integration/monte_carlo_integration.html It could be nice to add the same thing for other algorithms (visualization) by using gif. |
Well... We turned it down. No interactive visualization in the AAA. |
Sorry if I am asking a lot of questions but why Thanks for giving your time |
Hey @johhnry. We have an elm visualization for the forward euler method; however, that remains the only interactive visualization in the AAA so far. Even then, there was a heated debate as to whether it should be added in. Processing cannot be a dynamic visualization on the algorithm-archive.org (P5.js can, though?). Is the processing implementation of the algorithm (without the boilerplate visualization) different than Java? My understanding is that they are literally the same, except that the processing code is dropped into a Java class when the code is compiled. I am conflicted here. On the one hand, it looks like Processing is much easier to read and write than Java; however, if the implementation is literally the same, then no one will really be able to tell the difference in the AAA. This is a good discussion to have, so even if we decide to turn this PR down, it was really helpful. I would like to hear opinions from both sides. |
Another idea is having @johhnry work with @leios on a quality animation, like a gif, and have it displayed in a chapter, like we have in Monte Carlo or Split-Op. We can leave a note at the end saying that the visualization was done in Processing and show the code. I think that would be wonderful and very useful to people. |
Yeah, I agree with that @jiegillet. The only problem here is that for consistency, if we use one visualization method for Bogo Sort, we should use the same one for all the other sorts (and there are a lot of them). It's fine, so long as @johhnry is willing to help as more sorting chapters get added. |
I don't think consistency is a priority, if only one chapter has a visualization, it's better than nothing. If more do, all the better. |
I would love to! |
So what was the verdict on this PR? Do we close it and create a separate issue to discuss the visualization of sorting algorithms? Or do we keep it up and rework it for a general-case visualization with code available? |
@johhnry very nice! |
I think it would be understandable enough to highlight the two bars we are comparing. Once we have the visualization done, I'll send you a PR on this PR for you to merge so we can merge. |
Looks good! I would work on the timings a bit more. The swap is too slow and the non-swap are too fast :) |
I like the visualization. If you fix the timings, it will be great! That said, isn't that visualization for Bubble sort? This is a Bogo Sort PR. I can just change the name to Bubble Sort, though. |
Yes you are totally right @leios |
Love it! Bubble sort is good but it stops before the array is sorted, that's frustrating, maybe you can remove one or 2 elements. Also most AAA algorithm don't have the optimization of not going through the whole array when then end is already sorted, so maybe you shouldn't either. I'm not sure... |
Agreed, these are good. It would be nice if both of them finished on sorted arrays and waited for a second or something. |
Alright, I am happy with this visualization. Let me send a PR to your PR about this. |
What's up guys ? |
I have not. I've just been swamped lately. |
I finally got the PR in: https://github.com/johhnry/algorithm-archive/pull/2 |
adding processing visualization and small merges.
Hey @johhnry thanks a lot! Do you have a video of this animation as well? We have recently changed things to videos, if possible. If you don't have a video, no problem! |
Sure, how do I send it ? on Github? |
Since the repository has been deleted, I don't think it's merge-able any more, sadly. |
Added a new language, Processing.
Processing is a Java based programming language used for computer graphics, data visualisation, animation...
Checkout https://processing.org/.
Added the Processing version of the Bogo Sort algorithm with sorting visualisation.