-
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
Savannah #28
base: master
Are you sure you want to change the base?
Savannah #28
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.
Really nice work, I like how you used heapsort in place. You were also correct on all your time and space complexities. Well done.
# Time Complexity: ? | ||
# Space Complexity: ? | ||
# Time complexity: O(log(n)) | ||
# Space complexity: O(1) | ||
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: ? | ||
# Space complexity: ? | ||
# 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.
👍
|
||
# Time Complexity: O(n) => this is based of the math proof on geeks for geeks, not sure if I 100 % understand ... yet | ||
# Space Complexity: O(n) <= can optimize by using iterative approach over recursion |
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.
Correct, you can optimize it a bit further using iteration.
# Time Complexity: O(nlogn) | ||
# Space Complexity: O(n) |
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.
Correct by how you're using recursion to transform list
into a heap.
Heaps Practice
Congratulations! You're submitting your assignment!
Comprehension Questions
CQs answered on previous pull request (closed)
heap_up
&heap_down
methods useful? Why?Removed conflict =) For heap sort I wanted to try in place, otherwise I would have used the min heap, added each element to it then removed each element and pushed in to new list or index exisiting list 0 .. end to add elements.