-
Notifications
You must be signed in to change notification settings - Fork 5
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
Earth - Emily #3
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.
Overall nice work Emily. I had one comment on heap-down, but otherwise solid work.
// Time Complexity: O(nlogn)? | ||
// Space Complexity: O(n)? | ||
|
||
function heapsort(list) { |
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.
👍 Very clean!
Correct time/space complexity. No need for question marks!
// Time Complexity: O(logn)? | ||
// Space Complexity: 0(1)? | ||
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: O(1) | ||
// Space complexity: O(1) | ||
isEmpty() { |
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(1) Because we're only swapping?? | ||
// Space complexity: O(1)? | ||
heapUp(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.
You're doing recursion so the time complexity is O(log n) and space complexity is the same (system stack).
} | ||
|
||
this.swap(index, parent); | ||
this.heapUp(parent); | ||
} | ||
|
||
// This helper method takes an index and | ||
// moves it up the heap if it's smaller | ||
// than it's parent node. | ||
heapDown(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.
What about the situation if there is no right child, but there is a left child?
Not finished!
Would like some feedback on what is causing my last test in heapsort to fail. I realize there's something wrong with my heapDown(index) method in minheap.
Heaps Practice
Congratulations! You're submitting your assignment!
Comprehension Questions
heap_up
&heap_down
methods useful? Why?