subject
Mathematics, 21.03.2020 09:51 Yangster9305

Given the following code for a binary search, how many total times will this method have to be executed in order to find the number 5? int[] arr = {1, 3, 5, 6, 7, 9, 11, 15, 18} return binarySearch(arr, 0, 8, 5)//This counts as call number 1 //method int binarySearch(int arr[], int left, int right, int num) { if (right >= left) { int middle = left + (right - left) / 2; if (arr[middle] == num) return middle; if (arr[mid] > num) return binarySearch(arr, left, middle - 1, num); return binarySearch(arr, middle + 1, right, num); } return -1; }

ansver
Answers: 3

Other questions on the subject: Mathematics

image
Mathematics, 21.06.2019 18:00, sophiaa23
Louise measured the perimeter of her rectangular scrapbook to be 154 cm. if the scrapbook is 45 cm wide, how long is the scrapbook?
Answers: 1
image
Mathematics, 21.06.2019 20:40, brayann5761
What is the value of the expression i 0 × i 1 × i 2 × i 3 × i 4? 1 –1 i –i
Answers: 2
image
Mathematics, 21.06.2019 22:00, elondamason
Which of these triangle pairs can be mapped to each other using a single translation? cof hn
Answers: 2
image
Mathematics, 21.06.2019 22:00, jnkbragg3696
Problem situation: caren is making rice and beans. she can spend no more than $10 on ingredients. she buys one bag of rice for $4.99. beans cost $0.74 per pound. how many pounds of beans, x, can she buy? inequality that represents this situation: 10≥4.99+0.74x drag each number to show if it is a solution to both the inequality and the problem situation, to the inequality only, or if it is not a solution.
Answers: 1
You know the right answer?
Given the following code for a binary search, how many total times will this method have to be execu...

Questions in other subjects:

Konu
Mathematics, 28.05.2021 22:30
Konu
Mathematics, 28.05.2021 22:30
Konu
Mathematics, 28.05.2021 22:30
Konu
Chemistry, 28.05.2021 22:30
Konu
Mathematics, 28.05.2021 22:30