Conversation
kyra-patton
left a comment
There was a problem hiding this comment.
✨ Nice work! I left some comments on complexity below. Let me know what questions you have.
🟢
| larger than either of its children and continues until | ||
| the heap property is reestablished. | ||
| Time Complexity: Ologn | ||
| Space Complexity: O1 |
There was a problem hiding this comment.
✨ Space complexity is O(log n) here because of the recursive call stack
| Time complexity: ? | ||
| Space complexity: ? | ||
| Time complexity: Ologn | ||
| Space complexity: O1 |
There was a problem hiding this comment.
✨ Because of the recursive call stack, space complexity is O(log n)
| Time complexity: ? | ||
| Space complexity: ? | ||
| Time complexity: O1 | ||
| Space complexity: 01 |
| Time Complexity: ? | ||
| Space Complexity: ? | ||
| Time Complexity: Ologn | ||
| Space Complexity: O1 |
There was a problem hiding this comment.
✨ Because of the recursive call stack of heap_down, space complexity is O(log n)
| Time Complexity: ? | ||
| Space Complexity: ? | ||
| Time Complexity: Ologn | ||
| Space Complexity: On |
There was a problem hiding this comment.
✨ The space complexity here is determined by the recursive call stack of heap_up which is just O(log n)
| Time Complexity: ? | ||
| Space Complexity: ? | ||
| Time Complexity: On | ||
| Space Complexity: On |
There was a problem hiding this comment.
✨ Time complexity here will be O(n log n) where n is length of list. For each of n items in list, you perform heap.add()/heap.remove() which are both log n operations.
Heaps Practice
Congratulations! You're submitting your assignment!
Comprehension Questions
heap_up&heap_downmethods useful? Why?