-
Notifications
You must be signed in to change notification settings - Fork 40
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
Leaves - Samantha #33
base: master
Are you sure you want to change the base?
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.
I apologize for taking so long to look at this. You did a fantastic job here. The code is clean and readable and everything works well. A few small things on space complexity, otherwise great!
# Time Complexity: On(log n) | ||
# Space Complexity: O(1) | ||
def heap_sort(list) |
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 are building a heap here... so you DO have some space complexity even if that heap is empty by the end.
# Time Complexity: O(log n) | ||
# Space Complexity: O(log n) | ||
def add(key, value = key) |
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: O(log n) | ||
# Space Complexity: O(log n) | ||
def remove() |
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: O(1) | ||
# Space complexity: O(1) | ||
def empty? |
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: O(log n) | ||
# Space complexity: O(1) | ||
def heap_up(index) |
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 do have space complexity here brought upon by the recursion involved.
end | ||
|
||
|
||
# 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) |
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 clean code here I like it!
Thank you Chris! I appreciate the feedback.
…On Fri, Apr 17, 2020 at 1:06 PM Chris M ***@***.***> wrote:
***@***.**** commented on this pull request.
I apologize for taking so long to look at this. You did a fantastic job
here. The code is clean and readable and everything works well. A few small
things on space complexity, otherwise great!
------------------------------
In lib/heap_sort.rb
<#33 (comment)>:
> +# Time Complexity: On(log n)
+# Space Complexity: O(1)
def heap_sort(list)
You are building a heap here... so you DO have some space complexity even
if that heap is empty by the end.
------------------------------
In lib/min_heap.rb
<#33 (comment)>:
> + # Time Complexity: O(log n)
+ # Space Complexity: O(log n)
def add(key, value = key)
👍
------------------------------
In lib/min_heap.rb
<#33 (comment)>:
> + # Time Complexity: O(log n)
+ # Space Complexity: O(log n)
def remove()
👍
------------------------------
In lib/min_heap.rb
<#33 (comment)>:
> + # Time complexity: O(1)
+ # Space complexity: O(1)
def empty?
👍
------------------------------
In lib/min_heap.rb
<#33 (comment)>:
> + # Time complexity: O(log n)
+ # Space complexity: O(1)
def heap_up(index)
You do have space complexity here brought upon by the recursion involved.
------------------------------
In lib/min_heap.rb
<#33 (comment)>:
> end
-
+
# 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)
Very clean code here I like it!
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#33 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AMMQ6O7QG5HAUDTBINFZVTLRNCZFZANCNFSM4L6YAJKQ>
.
|
Heaps Practice
Congratulations! You're submitting your assignment!
Comprehension Questions
heap_up
&heap_down
methods useful? Why?