Skip to content
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

Dani Sanchez - Paper #1

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Conversation

danisandiaz
Copy link

Heaps Practice

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
How is a Heap different from a Binary Search Tree? A Heap is different because it is in semi-order.
Could you build a heap with linked nodes? You can build a heap with linked nodes using a queue.
Why is adding a node to a heap an O(log n) operation? It is a O(log n) operation because every time you add a node to a heap you could transverse the heap logarithmically according to it's size.
Were the heap_up & heap_down methods useful? Why? Yes they were very helpful in breaking up the logic into a recursive method that could be separated from the add and remove methods and called as many times as necessary.

Copy link

@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.

Note: You submitted the JS entry in the Python section.

Otherwise really nice work. Well done.

Comment on lines +5 to 7
// Time Complexity: O(n log n )
// Space Complexity: O(n)
function heapsort(list) {

Choose a reason for hiding this comment

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

👍

Comment on lines +14 to -17
// Time Complexity: O(log n)
// Space Complexity: O(log n)
add(key, value = key) {
throw new Error("Method not implemented yet...");

Choose a reason for hiding this comment

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

👍

Comment on lines +27 to 29
// Time Complexity: O(log n)
// Space Complexity: O(log n)
remove() {

Choose a reason for hiding this comment

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

👍

Comment on lines +54 to 56
// Time complexity: O(1)
// Space complexity: O(1)
isEmpty() {

Choose a reason for hiding this comment

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

👍

Comment on lines +63 to 65
// Time complexity: O(log n)
// Space complexity: O(log n)
heapUp(index) {

Choose a reason for hiding this comment

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

👍

Comment on lines 80 to 83
// This helper method takes an index and
// moves it up the heap if it's smaller
// than it's parent node.
heapDown(index) {

Choose a reason for hiding this comment

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

👍 Very compact

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