Question: 6. [4 marks] Briefly show how the binary search algorithm presented in class (shown below) searches for 48 in the following list: 3, 5, 7,

6. [4 marks] Briefly show how the binary search
6. [4 marks] Briefly show how the binary search algorithm presented in class (shown below) searches for 48 in the following list: 3, 5, 7, 9, 11, 16, 17, 23, 28, 31, 32, 37, 41, 42, 46, 49. procedure binary search (x: integer, a1, a2, . . ., an: increasing integers) i := 1 {i is left endpoint of search interval } j := n {j is right endpoint of search interval} while i am then i := m + 1 else j := m if x = a; then location := i else location := 0 return location {location is the subscript i of the term a; equal to x, or 0 if x is not found}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Mathematics Questions!