-
Notifications
You must be signed in to change notification settings - Fork 11
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
Earth - Ringo #4
base: master
Are you sure you want to change the base?
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 Ringo, you hit all the learning goals here. Well done.
// Time Complexity: O(log n) -- assuming the tree is balanced, as the number of nodes increases | ||
// the number of times addHelper has to be called will only increase logarithmically | ||
// Space Complexity: O(log n) -- assuming the tree is balanced, the number of calls to addHelper | ||
// that will be on the stack at one time increases logarithmically, rather than linearly | ||
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.
👍 Correct on complexity, with the assumption
// Time Complexity: O(log n) -- assuming the tree is balanced, as tree increases in size, | ||
// the number of times findHelper has to be called will only increase logarithmically | ||
// Space Complexity: O(log n) -- assuming the tree is balanced, the number of calls to findHelper | ||
// on the stack at one time increases logarithmically | ||
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.
👍 Correct on complexity, with the assumption
// Time Complexity: O(n). Method needs to visit every node in the tree | ||
// Space Complexity: O(log n). The number of function calls on the stack will only be as great | ||
// as the maximum height of the tree, which increases logarithmically to # of nodes (assuming balanced) | ||
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.
👍 Correct on complexity, with the assumption
// Time Complexity: O(n). Method needs to visit every node in the tree | ||
// Space Complexity: O(log n). The number of function calls on the stack will only be as great | ||
// as the maximum height of the tree, which increases logarithmically to # of nodes (assuming balanced) | ||
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.
👍 Correct on complexity, with the assumption
// Time Complexity: O(n). Method needs to visit every node in the tree | ||
// Space Complexity: O(log n). The number of function calls on the stack will only be as great | ||
// as the maximum height of the tree, which increases logarithmically to # of nodes (assuming balanced) | ||
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.
👍 Correct on complexity, with the assumption
// Time Complexity: O(n). Method needs to follow every branch to its end | ||
// and therefore visits every node. | ||
// Space Complexity: O(log n). The max number of function calls on the stack will | ||
// only be the maximum height of the tree, which scales logarithmically to the | ||
// size of the tree (if balanced) | ||
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.
👍 Correct on complexity, with the assumption
// Time Complexity: O(n). The method needs to visit every node in the tree so the time taken | ||
// will increase linear to the size of the tree increasing. | ||
// Space Complexity: O(n). The size of the queue at any point in time will increase logarithmically | ||
// with the size of the tree, but the results array will increase linear to the size of the tree. | ||
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.
👍 Correct on complexity
No description provided.