1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
avanturin [10]
3 years ago
12

In the recursive function findMatch(), the first call is findMatch(array, 0, 4, key) . What are the remaining function calls to

find the character 'e'?
public class FindMatch {
public static int findMatch(char array[], int low, int high, char key) {
if (high >= low) {
int mid = low + (high - low) / 2;
if (array[mid] == key) {
return mid;
}
if (array[mid] > key) {
return findMatch(array, low, mid, key);
}
else {
return findMatch(array, mid + 1, high, key);
}
}
return -1;
}
public static void main(String args[]){
char array[] = {'a','b','c','d','e'};
char key = 'e';
int result = findMatch(array, 0, 4, key);
if (result == -1) {
System.out.println("Element not found!");
}
else {
System.out.println("Element found at index: " + result);
}
}
}
a. (array, 2, 4, key) and (array, 3, 4, key)
b. (array, 2, 4, key), (array, 3, 4, key) and (array, 4, 4, key)
c. (array, 3, 4, key)
d. (array, 3, 4, key) and (array, 4, 4, key)
Computers and Technology
1 answer:
umka21 [38]3 years ago
5 0

Answer:

The answer is "Option D".

Explanation:

In the given question "(array, 3, 4, key) and (array, 4, 4, key)", the element 'e' to also be searched is concentrated mostly on the right-hand side of the array since it is in the last place. This same middle value is 2 but findMatch(array, mid + 1 high, key) is labeled twice to move the center pointer to its last position, that is, so move that search item's 'e.'

You might be interested in
Why is sequencing important?
S_A_V [24]

Answer:

C

Explanation:

If it wasn't in order then the code would fail

4 0
3 years ago
Read 2 more answers
Given a sorted list of integers, output the middle integer. Assume the number of integers is always odd. Ex: If the input is: 2
ser-zykov [4K]

Answer:

....................................

Explanation:

8 0
3 years ago
BlockPy: #38.2) While Input Use a while loop to repeatedly take input from the user and print whatever they type in. When the us
BARSIC [14]

Answer:

strr=input("please enter something: ")

while strr is not "":

   print(strr)

   strr=input("please enter something: ")

Explanation:

whenever the user will enter an empty string the loop will terminate

8 0
4 years ago
Your company has decided to replace several hundred hard drives. It would like to donate the old hard drives to a local school s
Tanzania [10]

Answer:

Drive Wipe F is correct

Explanation:

Drives content is virtual so it wouldn't work to shred or incinerate it. overwriting it wouldn't work to get rid of files exactly. it might get rid of the files but it would replace the files with other files.

3 0
3 years ago
A variable of type unsigned short stores a value of 0. If the variable value is incremented, what exception will occur?A. No exc
yulyashka [42]

There are different kinds of variable. The answers are below;

  • If the variable value is incremented, therefore, No <u>exception </u>will occur.
  •  If the variable value is incremented, An <u>Overflow </u>will occur
  • If the variable value is decremented no exception will occur.

<h3>What is Underflow?</h3>

Underflow is a known to be a process or exception that happens if a number calculation is too small to be shown by the CPU or memory.

what causes a overflow is the Adding to a variable when its value is at the upper end of the datatype range.

Learn more about variables from

brainly.com/question/24751617

3 0
3 years ago
Other questions:
  • Chunking is a good strategy for completing large assignments because it makes the work
    15·1 answer
  • Consider an application that transmits data at a steady rate (for example, the sender generates an N-bit unit of data every k ti
    8·1 answer
  • This folder is ndownload and it isn't like download file
    14·1 answer
  • Python
    14·1 answer
  • Who are the best candidates for members of SkillsUSA? Check all that apply. Adolph wants to be an Elementary School Teacher. Rub
    5·2 answers
  • Write a short program that uses a for loop to populate an array. The array can store up to 10 integers. Modify the code slightly
    12·1 answer
  • This function whose primary purpose is to display information to the user can only display one value at a time.
    15·1 answer
  • How do I convert years to days on Python. For example, if I were to enter 3 years it should output "You are 1095 days old".
    5·1 answer
  • You want to read input from the user to know how many apples they would like
    10·1 answer
  • what is the system that connects application repositories, systems, and it environments in a way that allows access and exchange
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!