Python Program for Depth First Binary Tree Search without using Recursion
The program creates a binary tree and presents a menu to the user to perform operations on the tree including a depth-first search. The methods insert_left and insert_right insert a node as the left and right child respectively. A variable is created to store the binary tree. What would you like to do? insert 1 at root What would you like to do? insert 2 left of 1 What would you like to do? insert 3 right of 1 What would you like to do? insert 4 right of 2 What would you like to do? insert 5 left of 4 What would you like to do? dfs What would you like to do? quit What would you like to do? insert 3 at root What would you like to do? insert 6 left of 3 What would you like to do? insert 7 right of 3 What would you like to do? insert 8 left of 7 What would you like to do? insert 10 right of 7 What would you like to do? dfs What would you like to do? quit
Aug-15-2021, 11:40:30 GMT
- Technology: