In: Computer Science
need algorithm not code otherwise will downvote 10
times use ms team or latex code or pdf only
Consider an n-node complete binary tree T, where n = 2d − 1 for
some d. Each node v of T is labeled with a real number xv. You may
assume that the real numbers labeling the nodes are all distinct. A
node v of T is a local minimum if the label xv is less than the
label xw for all nodes w that are joined to v by an edge.
You are given such a complete binary tree T, but the labeling is
only specified in the following implicit way: for each node v, you
can determine the value of xv by probing the node v. Show how to
find a local minimum of T using only O(logn) probes to the nodes of
T.
Note:- dont use handwritten image
/*Dear Student, As you requested for the only algorithm, I have spent a lot of time and made these statements with algorithms in a simple and clear manner, so if you got something from it, then give it an Upvote. Thank You.*/
Q) Local minimum of T using only O(logn) probes to the nodes of T.
Ans: The algorithm is the following.
To find the local minimum in T we evaluate localMin(r). The algorithm performs O(d) =O(log n) probes of the tree;
We must now argue that the returned value is a local minimum. If the root is returned it is a local minimum as explained above.
Algorithm: Local Minimum in tree T
LocalMin(v) //This function finds the local minimum in the subtree rooted at v in T.