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

Another question on Mathematics

question
Mathematics, 21.06.2019 15:30
What is this inequality notation? t is less then or equal to 2
Answers: 3
question
Mathematics, 21.06.2019 18:30
Analyze the graph of the cube root function shown on the right to determine the transformations of the parent function. then, determine the values of a, h, and k in the general equation.
Answers: 1
question
Mathematics, 21.06.2019 23:00
Perry observes the opposite parallel walls of a room in how many lines do the plains containing the walls intersect
Answers: 1
question
Mathematics, 21.06.2019 23:20
This graph shows which inequality? a ≀ –3 a > –3 a β‰₯ –3 a < –3
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
question
Mathematics, 21.08.2019 12:20
question
History, 21.08.2019 12:20
question
Mathematics, 21.08.2019 12:20
Questions on the website: 13722363