The sorted values array contains the sixteen integers 1, 2, 3, 13, 13, 20, 24, 25, 30, 32, 40, 45, 50, 52, 57, 60. How many recursive calls are made by our binarySearch method given an initial invocation of binarySearch(45, 0, 15)

Respuesta :

The number of recursive calls that have to be done using the binary search is 4.

How to do the recursive calls

binarySearch = (45, 0, 15)

start + end / 2 = value

mid = 0 + 15/2 = 7.5

The 7th element = 30

30 is less than 45

8 + 15/3

= 23/2 = 11.5

The 12th element = 52

52 is greater than 45

8 + 11/2

= 19/2 = 9.5

The value of 9 = 40 and 40 is less than 45

10+ 11/2 = 10.5

The tenth value is 45 hence the iteration to be done is 4.

Read more on binary here:

https://brainly.com/question/21475482

#SPJ1

ACCESS MORE
EDU ACCESS