-
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
Sarah #16
base: master
Are you sure you want to change the base?
Sarah #16
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.
Well done. You hit the learning goals here. Let me know if you have questions.
# Time Complexity: ? | ||
# Space Complexity: ? | ||
# Time Complexity: 0(n log n) where n is the length of the list. heapify iterates through the list and for each calls add() which is 0(log n) so thats n log n for heapify, heap sort is the same, n log n. So total its 0(2 * nlogn) which reduces to n log n | ||
# Space Complexity: 0(1), we create a new heap, but each time we add one, we remove one from the list. and then westart moving items one at a time back to the list. the length of the heap and the length of the list combined are always equal to the original list size, so we dont actually use any extra space. |
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 this sort has O(n) space complexity.
# Time complexity: ? | ||
# Space complexity: ? | ||
# Time complexity: O(log n) where n is the index | ||
# Space complexity: O(1) only use constant sized variables |
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, an iterative solution.
Heaps Practice
Congratulations! You're submitting your assignment!
Comprehension Questions
heap_up
&heap_down
methods useful? Why?