Scissors - Aida R.#50
Open
adia-9 wants to merge 1 commit intoAda-C15:masterfrom
Open
Conversation
CheezItMan
reviewed
Jan 11, 2022
CheezItMan
left a comment
There was a problem hiding this comment.
Well done Aida! You hit the learning goals here. Well done. Nice work getting BFS working.
| current_node.right = self.add_helper(current_node.right, key, value) | ||
| return current_node | ||
|
|
||
| def add(self, key, value = None): |
Comment on lines
+34
to
+36
| # Time Complexity: O(log n) if Balanced BST and O(n) for Unbalanced BST | ||
| # Space Complexity: O(log n) if Balanced BST and O(1) for Unbalanced BST | ||
| def find_helper(self, current, key): |
Comment on lines
+50
to
+53
| # Time Complexity: O(n) where n is each visited node | ||
| # Space Complexity: O(n) - O(h) for the call stack, where h is the height of the tree | ||
| # Inorder Traversal: Left - Root - Right | ||
| def inorder_helper(self, current, ascending_nodes): |
There was a problem hiding this comment.
👍 Since you're making a list of all the nodes the space complexity is O(n)
Comment on lines
+71
to
+74
| # Time Complexity: O(n) where n is each visited node | ||
| # Space Complexity: O(n) - O(h) for the call stack, where h is the height of the tree | ||
| # Preoder traversal: Root - Left - Right | ||
| def preorder_helper(self, current, preorder_nodes): |
There was a problem hiding this comment.
👍 Since you're making a list of all the nodes the space complexity is O(n)
Comment on lines
+92
to
+95
| # Time Complexity: O(n) where n is each visited node | ||
| # Space Complexity: O(n) - O(h) for the call stack, where h is the height of the tree | ||
| # Postorder traversal: Left - Right - Root | ||
| def postorder_helper(self, current, postorder_nodes): |
There was a problem hiding this comment.
👍 Since you're making a list of all the nodes the space complexity is O(n)
Comment on lines
+113
to
+115
| # Time Complexity: O(log n) if Balanced BST and O(n) for Unbalanced BST | ||
| # Space Complexity: O(n) where n is the number of nodes in a given binary tree. | ||
| def height_helper(self, current, current_height): |
There was a problem hiding this comment.
👍 The space complexity is correct if the tree could be unbalanced. If the tree is balanced it's O( log n )
Comment on lines
+131
to
133
| # # Time Complexity: O(n) where n is the number of nodes -1 except root | ||
| # # Space Complexity: O(?) | ||
| def bfs(self): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.