Skip to content

fix, test: Fix MinHeap sinkDown implementation, increase test coverage #135

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
merged 1 commit into from
Jun 12, 2023

Conversation

caojoshua
Copy link
Contributor

MinHeap would break if we extract from a heap of two elements that looks like

    A
  /    \
B    undef

It would bubble up the right child and get

  undef
  /
B

I added more tests for MinHeap that inserts/extracts everything, and would have failed before this patch. I also added equivalent tests for MaxHeap.

@appgurueu appgurueu merged commit b738c80 into TheAlgorithms:master Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants