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
Leno4ka [110]
3 years ago
10

java The maximum-valued element of an integer-valued array can be recursively calculated as follows: If the array has a single e

lement, that is its maximum (note that a zero-sized array has no maximum) Otherwise, compare the first element with the maximum of the rest of the array-- whichever is larger is the maximum value. Write an int method named max that accepts an integer array, and the number of elements in the array and returns the largest value in the array. Assume the array has at least one element.
Computers and Technology
1 answer:
adoni [48]3 years ago
7 0

Answer:

see explaination

Explanation:

MaxArray.java

public class MaxArray{

public static void main(String[] args) {

int a[] = {1,2,5,4,3};

int max = max (a, 5);

System.out.println("Max value is "+max);

}

public static int max (int a[],int size){

if (size > 0) {

return Math.max(a[size-1], max(a, size-1));

} else {

return a[0];

}

}

}

Output:

MaxArray

You might be interested in
When writing potential test questions, it is very important to use vocabulary words in their correct form. Please select the bes
Ilya [14]
The answer is True.

Hope I helped!
6 0
3 years ago
Read 2 more answers
How to delete a brainly account?
dmitriy555 [2]

Answer:

Fill the deletion form go to settings and open FAQ ..

7 0
3 years ago
Read 2 more answers
Write the definition of a function named alternator that receives no parameters and returns true the first time it is invoked, r
Nataly [62]

Answer:

The solution code is written in C++

  1. bool STATUS = true;
  2. bool alternator ()
  3. {
  4.    if(STATUS){
  5.        STATUS = false;
  6.        return true;
  7.    }else{
  8.        STATUS = true;
  9.        return false;
  10.    }
  11. }

Explanation:

We need a global variable to track the status of true or false (Line 1).

Next, create the function alternator (Line 2) and then check if current status is true, set the status to false but return the previous status boolean value (Line 5-6). At the first time of function invocation, it will return true.

The else block will set the STATUS to true and return the false (Line 7-9).

3 0
3 years ago
ANSWER ASAP!!!!!!
dsp73
The answer is D I think
8 0
3 years ago
Read 2 more answers
* Discuss how an individual’s access to a wide range of online services affects their ability to operate safely in the digital w
ehidna [41]
Honestly, no online service is safe anymore these days...People and even the government can get hacked easily with today's technology.You can search someone easily on websites like Google or Facebook and even read someone's tweets on Twitter because their account is not private. But what's the point of saying private if they can easily get hacked by someone. There is no safety these days that is why you have to be careful with what you post on the internet in general.In these times people have to be cautious to not slip and fall off the iceberg surrounded by sharks.
4 0
3 years ago
Other questions:
  • Being able to express your thoughts in an email is a primary technology skill. True or False
    8·2 answers
  • Paragraph on how atms work
    15·1 answer
  • 4. What aspect of the initial database planning process would the formula (0 + Pt × 3 + p)/5 be used in?
    5·1 answer
  • What type of malicious procedure involves using sniffing tools to capture network communications to intercept confidential infor
    7·1 answer
  • using C++ to sort user input. for example, user enter 25numbers and sort them from small to big or big to small, cout thesamlles
    6·1 answer
  • If a computer is not working properly,the best thing to do is ________?
    5·2 answers
  • Kara has been asked to create an employment application form for her company. Which of the following items can she use to make s
    10·1 answer
  • 1. What runs horizontally and is identified with numbers?
    12·2 answers
  • Name two materials that we can burn in order to get energy from biomass
    9·1 answer
  • Write an algorithm of telephone call system​
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!