-
Notifications
You must be signed in to change notification settings - Fork 44
Raisah #33
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
base: master
Are you sure you want to change the base?
Raisah #33
Conversation
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.
Nice work, you have the essential methods working well. You also made progress trying BST and delete, although they're not working. Well done
# 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) |
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(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) |
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), 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 |
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), 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 |
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), 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 |
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), 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
# couldn't get this to work in time :( | ||
def delete(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.
It's hard.
No description provided.