##EXPLAIN STEP BY STEP AND FILL INTHE BLANKS##
Posted: Fri May 20, 2022 1:39 pm
##EXPLAIN STEP BY STEP AND FILL INTHE BLANKS##
3. (10 points) Here is pseudocode which implementa binary search: procedure binary-search (: integer, as,..., increasing integers) - 1 (the left endpoint of the search interval) (the right endpoint of the search interval) while (i <j): if (x > ..) then: -m+1 else: - if (2-a) then: location - else: location : 0 return location Fill in the steps used by this implementation of binary search to find the location of 1 - 38 in the list ay - 17,ay - 22, a -25,04 -38, as - 40,00 -42, ay - 46, -54,4g - 59,00 - 61 • Step 1: Initially i- 1.9 - 10 so search interval is the entire list 41 - 17.03 - 22, a -25,04 -38, as - 40.06 - 42,01 - 46,- 54.0 = 59.41061 T- • Step 2: Since i- 1< -10, the algorithm enters the while loop. Using the values of and and so on From comparing and the updated values of i andre and- and so the new search interval is the sublist: . Step 3: Since the algorithm again enters the while loop again. Using the current values of rand : and so From comparing us and ... the updated values of i and are and) and so the new search interval is the sublist: . Step 4: Since: <. the algorithm again enters the while loop again. Using the current values of i andy: and so From comparing and the updated values of and are and so the new scarcli space in the sublist: Step 5: Since the algoritlu i tot enter the while loup. What does the algorithm do then, and what validees it round
3. (10 points) Here is pseudocode which implementa binary search: procedure binary-search (: integer, as,..., increasing integers) - 1 (the left endpoint of the search interval) (the right endpoint of the search interval) while (i <j): if (x > ..) then: -m+1 else: - if (2-a) then: location - else: location : 0 return location Fill in the steps used by this implementation of binary search to find the location of 1 - 38 in the list ay - 17,ay - 22, a -25,04 -38, as - 40,00 -42, ay - 46, -54,4g - 59,00 - 61 • Step 1: Initially i- 1.9 - 10 so search interval is the entire list 41 - 17.03 - 22, a -25,04 -38, as - 40.06 - 42,01 - 46,- 54.0 = 59.41061 T- • Step 2: Since i- 1< -10, the algorithm enters the while loop. Using the values of and and so on From comparing and the updated values of i andre and- and so the new search interval is the sublist: . Step 3: Since the algorithm again enters the while loop again. Using the current values of rand : and so From comparing us and ... the updated values of i and are and) and so the new search interval is the sublist: . Step 4: Since: <. the algorithm again enters the while loop again. Using the current values of i andy: and so From comparing and the updated values of and are and so the new scarcli space in the sublist: Step 5: Since the algoritlu i tot enter the while loup. What does the algorithm do then, and what validees it round