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 12:30
Find the sum of the following series. round to the nearest hundredth if necessary.
Answers: 1
question
Mathematics, 21.06.2019 16:00
Which term best describes the association between variables a and b? no association a negative linear association a positive linear association a nonlinear association a scatterplot with an x axis labeled, variable a from zero to ten in increments of two and the y axis labeled, variable b from zero to one hundred forty in increments of twenty with fifteen points in a positive trend.
Answers: 3
question
Mathematics, 21.06.2019 21:30
On #16 : explain how factoring a trinomial, ax^2+ bx+ c, when a does not equal 1 different from factoring a trinomial when a = 1.
Answers: 2
question
Mathematics, 21.06.2019 22:30
Ron has 8 caps and 4 of his caps are blue. thes rest of his cap are red. how many of ron's caps are red
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