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

Rachael-Waterrrrr #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

RachaelGomez
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 not inherently ordered like a binary search tree is
Could you build a heap with linked nodes? yes?
Why is adding a node to a heap an O(log n) operation? because it's important to swap the elements while adding the new node
Were the heap_up & heap_down methods useful? Why? Yes, deeply.

@RachaelGomez RachaelGomez changed the title passing all but one Rachael-Waterrrrr Jul 17, 2021
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 Rachael, this all looks good and the code works fine. No guesses on time/space complexity?

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.

👍 Space/Time Complexity?

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.

👍 Space/Time Complexity?

Comment on lines 25 to 29
# This method removes and returns an element from the heap
# maintaining the heap structure
# 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.

👍 Space/Time Complexity?

Comment on lines 67 to 69
# 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.

👍 Space/Time Complexity?

Comment on lines 85 to 88
# 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.

👍 Space/Time Complexity?

Nice work handling all three scenarios here.

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