Conversation
kyra-patton
left a comment
There was a problem hiding this comment.
🌸✨ Nice work Kristel, however there are a few issues with your heap_sort function and time complexity. Also, you left the comprehension questions blank. I'm grading this as a yellow, but please feel free to resubmit if you would like a green score! Let me know what questions you have!
🟡
| Time Complexity: ? | ||
| Space Complexity: ? | ||
| Time Complexity: O(n log n) | ||
| Space Complexity: O(n) |
There was a problem hiding this comment.
👀 Time and space complexity and overall logic flow are correct, however, your heap_sort tests are failing. See my comment below!
| Time Complexity: ? | ||
| Space Complexity: ? | ||
| Time Complexity: O(log n) | ||
| Space Complexity: O(1) |
There was a problem hiding this comment.
✨ Nice, however, space complexity is O(log n) because of the recursive call stack of the heap_up operation
| Time Complexity: ? | ||
| Space Complexity: ? | ||
| Time Complexity: O(log n) | ||
| Space Complexity: O(1) |
There was a problem hiding this comment.
✨ Very nice, however like above, the space complexity is O(log n) because of the recursive call stack of heap_down
| return f"[{', '.join([str(element) for element in self.store])}]" | ||
|
|
||
|
|
||
| def empty(self): |
| Time complexity: ? | ||
| Space complexity: ? | ||
| Time complexity: O(log n) | ||
| Space complexity: O(1) |
There was a problem hiding this comment.
✨ However space complexity is O(log n) because of the recursive call stack
| self.swap(parent, index) | ||
| self.heap_up(parent) | ||
|
|
||
| def heap_down(self, index): |
| heap = MinHeap() | ||
|
|
||
| for item in list: | ||
| heap = heap.add(item) |
There was a problem hiding this comment.
Your failing tests for heap_sort return AttributeError: 'NoneType' object has no attribute 'add'. Look at the return value for add and see if you can figure out why that might be 🤔
What are you setting the heap equal to here? Do you need to be?
Heaps Practice
Congratulations! You're submitting your assignment!
Comprehension Questions
heap_up&heap_downmethods useful? Why?