-
Notifications
You must be signed in to change notification settings - Fork 44
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
Leaves_Ga-Young #48
base: master
Are you sure you want to change the base?
Leaves_Ga-Young #48
Conversation
One for empty tree, one for tree_with_nodes
Add a test for the height method
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 not bad. Take a look at my comments, mostly on BigO, and let me know any questions you have. Otherwise well done.
# Time Complexity: O(log n) where n is number of nodes ? | ||
# Space Complexity: O(n) where n is number of nodes ? | ||
def add(key, value) |
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.
Since you're not add n
nodes to the tree the space complexity is O(1).
# Time Complexity: O(log n) where n is number of nodes ? | ||
# Space Complexity: O(1) or is this N/A? | ||
def find(key) |
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(n) where n is number of nodes | ||
# Space Complexity: O(n) where n is number of nodes | ||
def inorder |
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(n) where n is number of nodes | ||
# Space Complexity: O(n) where n is number of nodes | ||
def preorder |
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(n) where n is number of nodes | ||
# Space Complexity: O(n) where n is number of nodes | ||
def postorder |
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(n) where n is number of nodes | ||
# Space Complexity: O(1) | ||
def height |
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.
Since height_helper
is recursive, this is O(log n) for space complexity. Since you'll have log n recursive calls on the stack at any one time.
I originally forked this project from Ada-C11/tree-practice, and when I tried to go back to forking from Ada-C12/tree-practice instead, GitHub kept redirecting me to the already forked tree-practice repo from C11. Not sure why that happened or how to fix it, but I hope this is similar enough to the correct assignment.