Question: Now consider the decision trees of algorithms for solving this problem. To make the decision tree more explicit, we can augment the tree with square
Now consider the decision trees of algorithms for solving this problem. To make the decision tree more explicit, we can augment the tree with square nodes, which mean that a value of -1 is returned, indicating that x does not appear in the array L. The decision tree for binary search with n = 13, augmented in this fashion, is shown below.
Below, you are given two algorithms for searching in a sorted array. Each function is a minor modification of the binary search algorithm discussed in class.


(a) Draw the decision tree for Algorithm 1 with n = 7. If the tree has more than four levels, you only need to draw the first four levels (i.e., levels 0, 1, 2, and 3, where 0 is the root level).
(b) Based on your answer to (a), comment on the correctness of Algorithm 1.
(c) Draw the decision tree for Algorithm 2 with n = 7. If the tree has more than four levels, you only need to draw the first four levels (i.e., levels 0, 1, 2, and 3, where 0 is the root level).
(d) Based on your answer to (c), comment on the correctness of Algorithm 2.
1) 3 ) 5 8) 10) 12) 1) 3 ) 5 8) 10) 12)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
