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

Savannah #28

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

Savannah #28

wants to merge 5 commits into from

Conversation

qqdipps
Copy link

@qqdipps qqdipps commented Nov 6, 2019

Heaps Practice

Congratulations! You're submitting your assignment!

Comprehension Questions

CQs answered on previous pull request (closed)

Question Answer
How is a Heap different from a Binary Search Tree?
Could you build a heap with linked nodes?
Why is adding a node to a heap an O(log n) operation?
Were the heap_up & heap_down methods useful? Why?

Removed conflict =) For heap sort I wanted to try in place, otherwise I would have used the min heap, added each element to it then removed each element and pushed in to new list or index exisiting list 0 .. end to add elements.

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.

Really nice work, I like how you used heapsort in place. You were also correct on all your time and space complexities. Well done.

# Time Complexity: ?
# Space Complexity: ?
# Time complexity: O(log(n))
# Space complexity: O(1)
def remove()

Choose a reason for hiding this comment

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

👍

# Time complexity: ?
# Space complexity: ?
# Time complexity: O(log(n))
# Space complexity: O(1)
def heap_up(index)

Choose a reason for hiding this comment

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

👍


# Time Complexity: O(n) => this is based of the math proof on geeks for geeks, not sure if I 100 % understand ... yet
# Space Complexity: O(n) <= can optimize by using iterative approach over recursion

Choose a reason for hiding this comment

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

Correct, you can optimize it a bit further using iteration.

# Time Complexity: O(nlogn)
# Space Complexity: O(n)

Choose a reason for hiding this comment

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

Correct by how you're using recursion to transform list into a heap.

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