Skip to content

Conversation

@ktvoort123
Copy link

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 elements in higher levels are greater than or less than the items in lower levels (depending on if it is max or min heap). However, in a BST, the items from left to right are in order.
Could you build a heap with linked nodes? Yes, you can implement a heap with linked TreeNode objects, but it's easier to implement a heap with an array.
Why is adding a node to a heap an O(log n) operation? Adding a node to a heap is and O(log n) operation because there are Log n levels to the heap.
Were the heap_up & heap_down methods useful? Why? Yes, because it helps compare the nodes and swaps them if they are out of order when adding and removing nodes.

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