Question: (10 points) Employ the decrease and conquer strategy to write a recursive Python function to compute the depth of a binary tree. The depth of

(10 points) Employ the decrease and conquer strategy to write a recursive Python function to compute the depth of a binary tree. The depth of a binary tree is the longest distance from the root to any leaf. This problem is very similar to finding the nurfiber ot red nodes; inbinary irese. Here's the API: # Input: root node of a binary tree # output a number, which is the depth of the tree rooted by the input node def my_depth( a_rootnode ): # your code . . . tree.random_tree(20, colors-[r','g','b], seed-42) has depth 6. tree. random-tree(20, colorsr','g',b'], seed-13) has depth 5. tree.random_tree(10, colors-[r,g','b], seed-1) has depth 4
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
