-
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
Amy P #18
base: master
Are you sure you want to change the base?
Amy P #18
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.
Definitely some issues here. Take a look at my comments and let me know if you have questions.
end | ||
|
||
sorted = [] | ||
heap.each do |elem| |
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.
Heaps don't have a .each method.
heap.each do |elem| | |
while !heap.empty? |
|
||
sorted = [] | ||
heap.each do |elem| | ||
sorted << heap.remove(elem) |
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.
remove
doesn't take an argument.
# Time Complexity: O(log n), where n is the number of nodes in heap | ||
# Space Complexity: O(log n), where n is the number of nodes in heap |
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.
👍
# Time Complexity: ? | ||
# Space Complexity: ? | ||
# Time Complexity: O(log n), where n is the number of nodes in heap | ||
# Space Complexity: O(1) |
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_down
is recursive, you will be using the call stack, so the space complexity is O(log n)
Heaps Practice
Congratulations! You're submitting your assignment!
Comprehension Questions
heap_up
&heap_down
methods useful? Why?