-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Combined Min Heap and Max Heap classes #1494
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
Combined Min Heap and Max Heap classes #1494
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.
Looks mostly fine. Some points:
- The tests are pretty much duplicated. IMO it would be fine to test just min or max heap, then test that the comparator is being used at all with a small example of the opposite ordering. But I'm not terribly opposed to this; it needs to be tested one way or another.
- You got rid of explanatory comments. Please readd some. At the very least, please add JSDoc comments to public methods, and mark "private" methods (like
bubbleUp
,sinkDown
andswap
) as such using the#
prefix.
Yeah!You are right.I will work on that and get back to you. |
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.
As said, bubbleUp / sinkDown / swap should all be private (not just documented as private, but actually private by prefixing them with #
).
I assume the @Class tag is for classes implemented via constructor functions, not using ES6 class syntax
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.
Though you have some redundant tags there (e.g. there's no need for @private
for #method
s, no need to document the heap
member (which btw should maybe also be private)).
I did this under hactober fest will it be counted? |
Yes, it should be. From the Hacktoberfest website:
The last point is what I effectively just did :) |
Thanks a lot @appgurueu |
np, thank you for your contribution :) it's important that every now and then someone takes the time to refactor something |
@appgurueu are there any more issues that you would suggest me to work on? |
No, but if you see other places where code is duplicated (or that otherwise have low code quality and warrant a refactor - plenty of such cases in this repo), or want to add an interesting algorithm, feel free to open a PR :) |
Deduplicated the code of Minheap and Maxheap and used a single binary heap class.
Describe your change:
Checklist:
**Example:**UserProfile.js is allowed but userprofile.js,Userprofile.js,user-Profile.js,userProfile.js are not