subject

Consider the following method, which implements a recursive binary search. /** Returns an index in theList where target appears,
* if target appears in theList between the elements at indices
* low and high, inclusive; otherwise returns -1.
* Precondition: theList is sorted in ascending order.
* low >= 0, high < theList. size(), theList. size() > 0
*/
public static int binarySearch(ArrayList theList, int low, int high,
int target)
{
if (low > high)
{
return -1;
}
int middle = (low + high) / 2;
if (target == theList. get(middle))
{
return middle;
}
else if (target < theList. get(middle))
{
return binarySearch(theList, low, middle - 1, target);
}
else
{
return binarySearch(theList, middle + 1, high, target);
}
}
The following code segment appears in a method in the same class as binarySearch.

ArrayList theList = new ArrayList ();
for (int k = 10; k < 65; k = k + 5)
{
theList. add(k);
}
int result = binarySearch(theList, 0, theList. size() - 1, 45);
Including the call to binarySearch in the last statement of the given code segment, how many times will binarySearch be called before a value is returned?

1- A

2- B

3- C

4- D

8- E

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 14:30
The option enables you to modify a slide element in most presentation applications.
Answers: 2
question
Computers and Technology, 24.06.2019 07:30
Jason is working on a microsoft excel worksheet and he wants to create a print preview shortcut. his teacher asks him to access the customization option to create the new shortcut. which two tabs should jason select to place the print preview shortcut on the worksheet toolbar? a. new tab (custom) and new group (custom) b. new file tab (custom) and new tab (custom) c. new custom group and new command d. new custom tab and new command
Answers: 2
question
Computers and Technology, 24.06.2019 11:30
What does the https: // mean when you type in a website
Answers: 1
question
Computers and Technology, 24.06.2019 18:00
Explain the circumstances for which the interquartile range is the preferred measure of dispersion. what is an advantage that the standard deviation has over the interquartile range? choose the correct answer below. a. the interquartile range is preferred when the distribution is symmetric. an advantage of the standard deviation is that it increases as the dispersion of the data increases. b. the interquartile range is preferred when the data are not skewed or no have outliers. an advantage of the standard deviation is that it uses all the observations in its computation. c. the interquartile range is preferred when the distribution is symmetric. an advantage of the standard deviation is that it is resistant to extreme values. d. the interquartile range is preferred when the data are bell shaped. an advantage of the standard deviation is that it is resistant to extreme values. e. the interquartile range is preferred when the data are skewed or have outliers. an advantage of the standard deviation is that it uses all the observations in its computation. f. the interquartile range is preferred when the data are bell shaped. an advantage of the standard deviation is that it increases as the dispersion of the data increases.
Answers: 2
You know the right answer?
Consider the following method, which implements a recursive binary search. /** Returns an index in...
Questions
question
Mathematics, 13.03.2021 03:00
question
Mathematics, 13.03.2021 03:00
question
English, 13.03.2021 03:00
question
Computers and Technology, 13.03.2021 03:10
question
English, 13.03.2021 03:10