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
Instructions:Select the correct answer.
Tju [1.3M]
E) Keep  top and left margins equal but larger than other margins
4 0
3 years ago
Read 2 more answers
HELP!!!!!!!! my keyboard keeps acting up every time I press a random key on my keyboard when it stops working it works perfectly
iogann1982 [59]

Answer:

try unplugging it and replugging it in, make sure your keyboard is clean, that there aren't any crumbs underneath the keys.

they using it on a different device and see if it does the same thing.

Explanation:

5 0
3 years ago
Which manufacturing industry makes semiconductors that are used in a variety of systems?
aleksley [76]
Transportation equipment
7 0
3 years ago
In Microsoft Excel, repeated hashes (#####) imply which of the following?
shtirl [24]

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

3 0
3 years ago
Megahertz is a measurement of
Nataly_w [17]

Answer:

sound

Explanation:

this may be wrong sounds right though doesen't it?

3 0
3 years ago
Other questions:
  • An example of hardware is a _____. database spreadsheet monitor program used to enhance photos
    13·2 answers
  • Lydia used software and numerical data to create bar graphs. What software did she use?
    8·2 answers
  • What is the block of text at the bottom of the page called?
    7·1 answer
  • What are several different types of software, which sit in the middle of and provide connectivity between two or more software a
    13·1 answer
  • Put these steps for managing your study time in chronological order. 1 set aside the same time each day 2 Identify the best time
    14·1 answer
  • ¿Cuál es la potencia de una lámpara de incandescencia que se conecta a la red de 220 V, sabiendo que tiene una resistencia de 50
    8·1 answer
  • Which statement is true about customizing presentation programs? A. You can add multiple animations to an object in a slide with
    14·2 answers
  • Suppose that a computer can read or write a memory word in 5 nsec. Also suppose that when an interrupt occurs, all 32 CPU regist
    10·2 answers
  • Formulas should follow the___
    9·1 answer
  • A taxi cab costs $1.25 for the first mile and $0.25 for each additional mile. Write an
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!