Skip to content
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

Dani - Leaves #36

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Dani - Leaves #36

wants to merge 2 commits into from

Conversation

dnsanche
Copy link

Heaps Practice

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
How is a Heap different from a Binary Search Tree? The binary search tree keeps the property that the left children is smaller than parent and right child is greater than parent. This is repeated for all nodes. In a heap, the only condition is that the parent needs to be smaller than the children nodes or greater, depending if its min or max heap.
Could you build a heap with linked nodes? yes, but it is more complicated.
Why is adding a node to a heap an O(log n) operation? You add the node at the end of the array O(1) and then you need to swap with parent. Since there are O(log(n)) levels, there will be a max of Olog(n) operations.
Were the heap_up & heap_down methods useful? Why? When adding the node and removing the node, because you need to keep the condition of the min or max heap.

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.

1 participant