Question: Question 3 a) The Python function below searches the contents of a balanced binary tree. If an upper limit of 1,000,000 nodes is assumed what
Question 3
a) The Python function below searches the contents of a balanced binary tree. If an upper limit of 1,000,000 nodes is assumed what should the max_stack_depth constant be set to?
b) If the assumptions regarding the tree are wrong, what is at risk of occuring?

Python .38 KB 1.I # stack-depth is initialised to 0 2. def find_in_tree(node, find_condition, stack_depth): 3. 4 5 6 7. 8 9 assert (stack-depth max-stack-depth), 'Deeper than max depth' stack depth += 1 result [] if find_ : condition(node) result += [node] for child node in node.children: result.extend(find_in_tree(child_node, find_condition, stack_depth)) 10. return result
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
