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

Erica #19

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

Erica #19

wants to merge 3 commits into from

Conversation

norrise120
Copy link

Heaps Practice

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
How is a Heap different from a Binary Search Tree? A heap is a complete binary tree, meaning that the last row is filled left to right with the proceeding rows being completely full.
Could you build a heap with linked nodes? Yes--but just because you can, doesn't mean you should!
Why is adding a node to a heap an O(log n) operation? Because the tree is split, so you only need to navigate through a fraction of the nodes and not every node.
Were the heap_up & heap_down methods useful? Why? Yes! Because it helped to make sure that the heap was in order as required.

Copy link

@CheezItMan CheezItMan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work. You hit all the learning goals here. Well done. Take a look at my comments and let me know if you have any questions.

Comment on lines +2 to +3
# Time Complexity: O(n log n) where n is the number of items in the list
# Space Complexity: O(n) where n is the number of items in the list

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

# Time Complexity: ?
# Space Complexity: ?
# Time Complexity: O(log n) where n is the number of items in the heap
# Space Complexity: O(1)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since your heap_up method is recursive you have to consider the call stack in terms of the space complexity.

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.

2 participants