-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
124 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,36 @@ | ||
from Node import Node | ||
|
||
if __name__ == "__main__": | ||
Root = Node() | ||
Tree = Node() | ||
|
||
numbers = [78, 52, 31, 49, 89, 35, 32, 73, 58, 25, 11, 100, 38, 1, 76, 18, 51, 82, 21] | ||
# numbers = [19, 12, 15, 21, 25, 30, 3, 1, 4, 6, 7, 10, 9] | ||
# numbers = [37, 28, 25, 37, 26, 17, 34, 36, 50, 47, 48, 46, 60, 58] | ||
# numbers = [78, 52, 31, 49, 89, 35, 32, 73, 58, 25, 11, 100, 38, 1, 76, 18, 51, 82, 21, 2, 4, 3, 5, 6, 8, 7] | ||
# numbers = [] | ||
|
||
for i in numbers: | ||
Root.insert_value(i) | ||
size = int(input("Write how many numbers you want to insert: ")) | ||
|
||
# number_to_search = int(input("Write number to find in tree: ")) | ||
for _ in range(size): | ||
number = int(input("Input number: ")) | ||
Tree.insert_value(number) | ||
|
||
min_value = Root.get_min_value() | ||
max_value = Root.get_max_value() | ||
# searched_value = Root.find_value(number_to_search) | ||
node_count = Root.get_node_count() | ||
tree_height = Root.get_height() | ||
min_value = Tree.get_min_value() | ||
max_value = Tree.get_max_value() | ||
node_count = Tree.get_node_count() | ||
Tree.display() | ||
|
||
# print(f'Number searched for: {number_to_search}. Does it belong to the tree? {searched_value}') | ||
print(f'Minimum value in tree: {min_value}') | ||
print(f'Maximum value in tree: {max_value}') | ||
print(f'The number of nodes is: {node_count}') | ||
print(f'Tree height: {tree_height}') | ||
Root.display_preorder() | ||
print(f'Number of nodes is: {node_count}') | ||
Tree.display_preorder() | ||
print() | ||
Root.display_inorder() | ||
Tree.display_inorder() | ||
print() | ||
Root.display_postorder() | ||
Tree.display_postorder() | ||
print() | ||
number_to_search = int(input("Write number to find in tree: ")) | ||
searched_value = Tree.find_value(number_to_search) | ||
print(f'Number searched for: {number_to_search}. Does it belong to the tree? {searched_value}') | ||
print() | ||
number_to_delete = int(input("Write number to delete from tree: ")) | ||
Tree.delete_value(number_to_delete) | ||
Tree.display() |