Skip to content

Conversation

@thenora
Copy link

@thenora thenora commented Oct 6, 2020

Heaps Practice

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
How is a Heap different from a Binary Search Tree? In a heap the items below the parent item are lower (for a max) or higher in the case of a min heap. They aren't sorted left to right though. Whereas in a binary search tree, there's not only order from top to bottom, but also left to right.
Could you build a heap with linked nodes? Yes, but better to use an array
Why is adding a node to a heap an O(log n) operation? There are only two children, and it chooses one of two, which is a base 2.
Were the heap_up & heap_down methods useful? Why? Yes, because they compare the new node to the parent and swaps them if they are out of order.

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