Skip to content

Conversation

@antoniairizarry
Copy link

Heaps Practice

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
How is a Heap different from a Binary Search Tree? Heap makes sure elements on higher levels are greater (or smaller than elements on lower levels, Binary Search Trees order from left to right.
Could you build a heap with linked nodes? Yes.
Why is adding a node to a heap an O(log n) operation? Because it needs to go through the height of the tree.
Were the heap_up & heap_down methods useful? Why? They help in rearranging the tree while maintaining structure.

@antoniairizarry antoniairizarry changed the title implemented methods, tests passing Space - Antonia Oct 8, 2020
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.

Nice work Antonia, except for missing time/space complexity you hit the learning goals here. Well done.

Comment on lines 4 to 6
# Time Complexity: ?
# Space Complexity: ?
def heap_sort(list)

Choose a reason for hiding this comment

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

👍

Comment on lines 17 to 19
# Time Complexity: ?
# Space Complexity: ?
def add(key, value = key)

Choose a reason for hiding this comment

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

👍

Comment on lines 26 to 28
# Time Complexity: ?
# Space Complexity: ?
def remove()

Choose a reason for hiding this comment

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

👍 , noting you're missing time/space complexity

Comment on lines 54 to 56
# Time complexity: ?
# Space complexity: ?
def empty?

Choose a reason for hiding this comment

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

👍 , noting you're missing time/space complexity

Comment on lines 65 to 67
# Time complexity: ?
# Space complexity: ?
def heap_up(index)

Choose a reason for hiding this comment

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

👍 , noting you're missing time/space complexity

Comment on lines 76 to 79
# This helper method takes an index and
# moves it up the heap if it's smaller
# than it's parent node.
def heap_down(index)

Choose a reason for hiding this comment

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

👍 , noting you're missing time/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