Skip to content

Kirsten#1

Open
kanderson38 wants to merge 1 commit intoAda-C11:masterfrom
kanderson38:master
Open

Kirsten#1
kanderson38 wants to merge 1 commit intoAda-C11:masterfrom
kanderson38:master

Conversation

@kanderson38
Copy link
Copy Markdown

Heaps Practice

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
How is a Heap different from a Binary Search Tree? In a min-heap, every child is larger than its parents; in a BST, a smaller node goes to the left of its parent, and a larger node goes to the right.
Could you build a heap with linked nodes? You could, but it's much easier to use an array.
Why is adding a node to a heap an O(log n) operation? You compare the new node to its parent and swap until it's in the right place -- this parent/child comparison can happen up to log n times.
Were the heap_up & heap_down methods useful? Why? They made it possible to reestablish the heap order when nodes were added or removed, so they were not just useful, but necessary.

Copy link
Copy Markdown

@CheezItMan CheezItMan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, this is perfect. Excellent job!

Comment thread lib/heapsort.js
// Space Complexity: ?
// Time Complexity: O(n log n), where n is the number of elements to be sorted
// Space Complexity: O(n), where n is the number of elements to be sorted
function heapsort(list) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants