-
Notifications
You must be signed in to change notification settings - Fork 34
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
Kim <3 <3 <3 #5
base: master
Are you sure you want to change the base?
Kim <3 <3 <3 #5
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! You hit all the learning goals here. Well done.
minHeap.add(list.pop) | ||
end | ||
|
||
until minHeap.empty? | ||
list << minHeap.remove | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very clear and elegant.
# Time Complexity: ? | ||
# Space Complexity: ? | ||
# Time Complexity: O(log n) - where n is the number of heap nodes | ||
# Space Complexity: O(1) - constant |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since heap_up
is recursive... You do have some space complexity here. The system stack.
# Time Complexity: ? | ||
# Space Complexity: ? | ||
# Time Complexity: O(log n) - where n is the number of heap nodes | ||
# Space Complexity: O(1) - constant |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
# Time complexity: ? | ||
# Space complexity: ? | ||
# Time complexity: O(log n) - where n is the number of heap nodes | ||
# Space complexity: O(mn) - where m is the space the recursive call is taking up on the stack, and n is the max depth of the tree |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since m
is likely to be constant in size, this is O(n)
Heaps Practice
Congratulations! You're submitting your assignment!
Comprehension Questions
heap_up
&heap_down
methods useful? Why?