-
Notifications
You must be signed in to change notification settings - Fork 1
Traversal bst #2
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?
Conversation
…o bst Merging branch bst.
…o bst sdf building a binary search tree.
…ctures into traversal-bst g g Lines starting with '#' will be ignocquire post_order_trav. red, and an empty message aborts
| """ | ||
| if self.root is None: | ||
| return 0 | ||
| return self.calc_depth(self.root.right) - self.calc_depth(self.root.left) |
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.
According to specs, left heavy is positive
| return 0 | ||
| return self.calc_depth(self.root.right) - self.calc_depth(self.root.left) | ||
|
|
||
| def in_order(self): |
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.
I personally like how you are able to have both the generator method, and also be able to simply return the value
| self.insert(value) | ||
| except TypeError: | ||
| self.insert(if_iter) | ||
| self._in_order = self.in_order_trav() |
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.
What happens if you create a tree with some nodes in it, but then start a traversal, and then add nodes into it before you have completed it?
No description provided.