Question
Question 4: Implement the following function: def find_min_abs_difference(bst) The function is given a binary search tree bst, where all its keys are non-negative numbers. When
Question 4: Implement the following function: def find_min_abs_difference(bst) The function is given a binary search tree bst, where all its keys are non-negative numbers. When called, it returns the minimum absolute difference between keys of any two nodes in bst. For example, if bst is the following tree: The call find_min_abs_difference(bst) should return 1 (since the absolute difference between 6 and 7 is 1, and there are no other keys that their absolute difference is less than 1)
.Implementation requirement: The runtime of this function should be linear. That is, if bst contains n nodes, this function should run in ?(). Hint: To meet the runtime requirement, you may want to define an additional, recursive, helper function, that returns more than one value (multiple return values would be collected as a tuple).
PYTHON
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started