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:00
Which value of c would make he following expression completely factored? 8x+cy
Answers: 1
question
Mathematics, 22.06.2019 00:30
Aline has a slope of negative 1/4 the past two points -5/4 and 1 what is the equation of the line
Answers: 2
question
Mathematics, 22.06.2019 01:00
The dance committee of pine bluff middle school earns $72 from a bake sale and will earn $4 for each ticket they sell to the spring fling dance. the dance will cost $400 write an inequality to determine the number, t of tickets the committee could sell to have money left over after they pay for this year's dance. what is the solution set of the inequality?
Answers: 2
question
Mathematics, 22.06.2019 01:50
Our star pitcher, foster enlight, can throw a pitch so fast that it gets to the catcher’s mitt before it leaves foster’s fingers! if the team wins a game then the probability that foster was pitching is 0.8 but only if foster had at least one day’s rest since his last pitching assignment. if foster does not have a day off and the team still wins, the probability that foster was pitching drops by half of what it was on the previous day. if the team wins three games in succession from the toronto tachyons and foster pitched in game #2, what is the probability that he pitched in one or more of the other games? (assume that foster did not pitch on the day before the first game of this three game series.)
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, 06.05.2020 04:29
Questions on the website: 13722367