Skip to content

Conversation

@dnguye2
Copy link

@dnguye2 dnguye2 commented Dec 30, 2020

Heaps Practice

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
How is a Heap different from a Binary Search Tree? Heaps only have ordering in which the children nodes are less than or greater than its parent depending on whether it is a max or min heap. BSTs on the other hand have its siblings sorted in either a (preorder/postorder/inorder) fashion.
Could you build a heap with linked nodes? Yup
Why is adding a node to a heap an O(log n) operation? To add a node we always add it to the bottom of the heap and bubble up the node to its correct place, in the worst case this means traversing the height of the tree which has a height of logn.
Were the heap_up & heap_down methods useful? Why? Yes it allowed to maintain the heap structure when adding or removing a node

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