-
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
Branches - Brianna #1
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.
Nicely done, you hit the learning goals here. Awesome work. Do take a look at my comments on time/space complexity. Otherwise well done.
lib/heapsort.js
Outdated
// Time Complexity: O(log n) | ||
// 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.
You're adding n elements to a heap (each add is log n) and so this sort is O(n log n) time complexity.
lib/minheap.js
Outdated
// 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.
👍
lib/minheap.js
Outdated
// Time complexity: O(log n) - n: nodes in heap | ||
// Space complexity: O(log n) or O(1)? | ||
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.
For space complexity are you creating any new data structures? Are you making recursive calls? If not it's O(1).
Otherwise this works.
Heaps Practice
Congratulations! You're submitting your assignment!
Comprehension Questions
heap_up
&heap_down
methods useful? Why?