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
nikklg [1K]
3 years ago
10

The elements of an integer-valued array can be initialized so that a[i] == i in a recursive fashion as follows: An array of size

0 is already initialized; Otherwise set the last element of the array to n-1 (where n is the number of elements in the array, for example, an array of size 3 will have its last element -- index 2-- set to 2; and initialize the portion of the array consisting of the first n-1 elements (i.e., the other elements of the array) Write a void method named init that accepts an integer array, and the number of elements in the array and recursively initializes the array so that a[i] == i.
Computers and Technology
1 answer:
blondinia [14]3 years ago
4 0

Answer:

public static void init(int[] arr, int n) {

    if (n==0)

        arr[0] = 0;

    else {

        arr[n-1] = n - 1;

        init(arr, n-1);

    }

}

Explanation:

Create a method called init that takes two parameters, an array and the number of elements in the array

When n reaches 0, set the first element to 0 (This is a base for our recursive method)

Otherwise, set the element in index i to i

Call the init inside the init, this is the recursion part, with same array but decrease the number of elements by 1 (We decrease the number of element by 1 in each time so that it goes through all the elements in the array)

You might be interested in
Which of the following color palettes for the BackColor and ForeColor properties contains colors that are guaranteed to be displ
Norma-Jean [14]

Answer: 1)System Palette

Explanation: System palette is kind of palette found in the system which contain the color values that is used by the display.This palette is also  drawing of the devices and applications.But the application don't get the direct access to the system palette rather logical palette permits it.

They work on the basis of the properties carried from the Back color and Fore color.Other palettes mention in the option is incorrect because these palettes don't work for the operating system's display .Thus the correct option is option(1).

8 0
3 years ago
you are a bank loan officer. carter has to come into your office and applied for a loan for a car.you ran his credit report, and
elena-14-01-66 [18.8K]

Answer:

Carter score falls within the range of scores, from 300 to 579, considered Very Poor. Score is significantly below the average credit score.

Explanation:

5 0
3 years ago
IPv4 address are of how many types?<br>​
Butoxors [25]

Answer: four different types

There are four different types of IPv4 addresses: public, private, static, and dynamic. While the public and private are indicative of the location of the network—private being used inside a network while the public is used outside of a network—static and dynamic indicate permanency.

7 0
3 years ago
I'll mark you the brainlest please help
nikklg [1K]

Hello There!

<u>ANSWER:</u>

<u></u>

C.

Hopefully, this helps you!!

AnimeVines

3 0
3 years ago
Read 2 more answers
You want to view a list of users on a linux system. what command should you use?
vredina [299]
Answer is A: cat /use/passwd
7 0
1 year ago
Other questions:
  • What technology process would help you access files at all times?
    11·1 answer
  • The IP address is a _____ bit number.
    5·1 answer
  • Get these points why they hot!!!!!!!!!!!!!!!!!!!!
    14·2 answers
  • g Q 2 Suppose I need a data structure having the following characteristics: a) must be very space efficient, and b) I have a goo
    6·1 answer
  • after clicking the start button on your computer screen desktop what option would you then select to examines system components
    8·1 answer
  • ​Lara is the chief editor of "Laughter and Life," an online magazine. Lara has assigned Jenny the task of redesigning the magazi
    5·1 answer
  • By
    7·1 answer
  • The role of Operating system<br><br>​
    6·1 answer
  • WILL GIVE BRAINLIEST!!!!!! 10 POINTS!!!!
    14·2 answers
  • What is the "Driver's Compact Law"?
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!