Open
Conversation
CheezItMan
reviewed
Feb 26, 2020
CheezItMan
left a comment
There was a problem hiding this comment.
Nice work, you have the essential methods working well. You also made progress trying BST and delete, although they're not working. Well done
Comment on lines
+19
to
21
| # Time Complexity: O(logn), at worst, the algorighm will be called O(logn) times to add the new node to the bottom of the tree. | ||
| # Space Complexity: O(1) the amount of data stored is constant, though the space required in memory for the stack trace will be O(logn) | ||
| def add(key, value) |
Comment on lines
+43
to
45
| # Time Complexity: O(logn), at worst, the algorighm will be called O(logn) times to add the new node to the bottom of the tree. | ||
| # Space Complexity: O(1) the amount of data stored is constant, though the space required in memory for the stack trace will be O(logn) | ||
| def find(key) |
Comment on lines
+65
to
67
| # Time Complexity: O(n), because the algorithm will have to visit every node on the tree to add them to the nodes_array list | ||
| # Space Complexity: O(n) because the size of the nodes_array list will vary linearly with the number of nodes in the tree. | ||
| def inorder |
Comment on lines
+81
to
83
| # Time Complexity: O(n), because the algorithm will have to visit every node on the tree to add them to the nodes_array list | ||
| # Space Complexity: O(n) because the size of the nodes_array list will vary linearly with the number of nodes in the tree. | ||
| def preorder |
Comment on lines
+97
to
99
| # Time Complexity: O(n), because the algorithm will have to visit every node on the tree to add them to the nodes_array list | ||
| # Space Complexity: O(n) because the size of the nodes_array list will vary linearly with the number of nodes in the tree. | ||
| def postorder |
Comment on lines
+113
to
115
| # Time Complexity: O(n), because the algorithm will have to visit every node on the tree in order to determine the height of the tree | ||
| # Space Complexity: O(1) because the amount of data stored is constant, though the space required in memory for the stack trace will be O(n) | ||
| def height |
There was a problem hiding this comment.
Comment on lines
+131
to
133
| # Time Complexity: O(n), because the algorithm will have to visit every node on the tree to add them to the nodes_array list | ||
| # Space Complexity: O(n) because the size of the nodes_array list will vary linearly with the number of nodes in the tree. | ||
| def bfs |
There was a problem hiding this comment.
Unfortunately this is more like a preorder traversal, this is because you traverse the entire left subtree before you traverse the right subtree. Remember all nodes at level 2 should be next to each other in the array and level 3 etc.
Comment on lines
+156
to
+157
| # couldn't get this to work in time :( | ||
| def delete(key) |
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.