-
Notifications
You must be signed in to change notification settings - Fork 51
Sarah S - Seattle #13
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
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.
✨💫 Nice work! I left some comments on time and space complexity. Let me know what questions you have.
🟢
|
||
|
||
def heap_sort(list): | ||
def heap_sort(l): |
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 length of self.store (??) | ||
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.
✨ Nice job on the time complexity, however space complexity would also be O(log n) because of the recursive call stack created by heap_up
else: | ||
return | ||
|
||
def remove(self): |
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 and space complexity?
return f"[{', '.join([str(element) for element in self.store])}]" | ||
|
||
|
||
def empty(self): |
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.
✨
This could be **very** helpful for the add method. | ||
Time complexity: O(log n) where n is the length of self.store (??) | ||
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.
✨ However because of heap_up
's recursive call, space complexity is O(log n).
|
||
return removed.value | ||
|
||
def heap_down(self, 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.
✨
Heaps Practice
Congratulations! You're submitting your assignment!
Comprehension Questions
heap_up
&heap_down
methods useful? Why?