Skip to content

Bst traverse#12

Open
jefimenko wants to merge 22 commits intobstfrom
bst-traverse
Open

Bst traverse#12
jefimenko wants to merge 22 commits intobstfrom
bst-traverse

Conversation

@jefimenko
Copy link
Owner

No description provided.

bst.py Outdated
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These functions do not work the way you think they do. Have you tried to play with them at the command line?

>>> from bst import Bst
>>> tree = Bst()
>>> for val in [5,3,7,4,1,6,8]:
...   tree.insert(val)
...
>>> tree.top
5
>>> tree.tree
{1: {'depth': 3}, 3: {'depth': 2, 'right': 4, 'left': 1}, 4: {'depth': 3}, 5: {'depth': 1, 'right': 7, 'left': 3}, 6: {'depth': 3}, 7: {'depth': 2, 'right': 8, 'left': 6}, 8: {'depth': 3}}
>>> [val for val in tree.in_order()]
[]
>>> [val for val in tree.pre_order()]
[5]
>>> [val for val in tree.post_order()]
[]
>>> [val for val in tree.breadth_first()]
[5, 3, 7, 1, 4, 6, 8]

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These methods will be helpful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants