-
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
Sockets-Bita #24
base: master
Are you sure you want to change the base?
Sockets-Bita #24
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.
Not bad, you do have a small bug in heap_down
that the heapsort tests found. Take a look and let me know if you have questions.
I'd like you to try to do the time and space complexity, you can't learn if you don't make attempts at it.
return | ||
end | ||
if @store[right_child] == nil | ||
if @store[index] > @store[left_child] |
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.
You should be comparing the keys here.
if @store[index] > @store[left_child] | |
if @store[index].key > @store[left_child].key |
# Time Complexity: ? | ||
# Space Complexity: ? |
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.
No time or space complexity?
@@ -17,15 +17,23 @@ def initialize | |||
# Time Complexity: ? | |||
# Space Complexity: ? | |||
def add(key, value = key) | |||
raise NotImplementedError, "Method not implemented yet..." | |||
new_node = HeapNode.new(key, value) | |||
new_node_index = @store.length |
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.
I don't think you really need this.
Heaps Practice
Congratulations! You're submitting your assignment!
Comprehension Questions
heap_up
&heap_down
methods useful? Why?