Question: Assignment In the provided example code ( lab 1 0 . py ) , a sample binary tree has been provided. Implement the incomplete functions:

Assignment
In the provided example code (
lab10.py), a sample binary tree has been provided. Implement the incomplete functions:
traversePreOrder() method should print the values of the given binary tree nodes according to pre-order traversal strategy
trim() method should decrease the values of every node of the tree by 1
trim_leaves() method should decrease the values of every LEAF node by 1
mirror() method should swap the left and right subtrees
Note: Only complete the #TODO items of the given code. If your implementation is correct, The output of the program should be similar to:
Original tree:
39458
After trimming entire tree:
28347
After trimming the leaves:
28236
After switching branch values:
26832
 Assignment In the provided example code ( lab10.py), a sample binary

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!