File tree Expand file tree Collapse file tree 1 file changed +14
-14
lines changed Expand file tree Collapse file tree 1 file changed +14
-14
lines changed Original file line number Diff line number Diff line change 11# Binary Search Tree in Python
22
33This project implements a Binary Search Tree (BST) in Python with basic operations:
4- - Insert values ( ` append ` )
4+ - Insert values
55- Remove values (` remove_value ` )
66- Traversals (pre-order, in-order, post-order)
77- Search for values
@@ -18,9 +18,9 @@ If you just want to try the tree without installing anything, copy **`tree.py`**
1818from tree import Tree
1919
2020tree = Tree()
21- tree.append (5 )
22- tree.append (3 )
23- tree.append (7 )
21+ tree.insert (5 )
22+ tree.insert (3 )
23+ tree.insert (7 )
2424tree.print_in_order()
2525```
2626
@@ -43,9 +43,9 @@ Now you can import it anywhere:
4343from bst import Tree
4444
4545tree = Tree()
46- tree.append (10 )
47- tree.append (4 )
48- tree.append (12 )
46+ tree.insert (10 )
47+ tree.insert (4 )
48+ tree.insert (12 )
4949tree.print_in_order()
5050```
5151
@@ -58,13 +58,13 @@ from bst import Tree
5858
5959# Create tree and insert values
6060test = Tree()
61- test.append (5 )
62- test.append (8 )
63- test.append (6 )
64- test.append (9 )
65- test.append (3 )
66- test.append (4 )
67- test.append (2 )
61+ test.insert (5 )
62+ test.insert (8 )
63+ test.insert (6 )
64+ test.insert (9 )
65+ test.insert (3 )
66+ test.insert (4 )
67+ test.insert (2 )
6868
6969# Remove values
7070test.remove_value(5 ) # Removes root
You can’t perform that action at this time.
0 commit comments