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
Accepted identifier for a variable in PHP except:
olganol [36]

Answer:

b. & Puihaha

Explanation:

PHP variables are supposed to start with a $ sign.

Other rules followed by PHP variables are:

Starting character in variable name (after $) must be letter or _.

Other characters in variable names can be letters,numbers or _.

a. $_Puihaha

c. $Pui_haha

d. $Puihaha

satisfy these rules.

Whereas , b. & Puihaha does not satisfy as it starts with '&'. Moreover it also contains an invalid space character in the variable.

3 0
3 years ago
2. You can ___ adjust to NOT sleeping at night.
zhannawk [14.2K]

Answer:

whats the answer chooses

Explanation:

7 0
3 years ago
Computer viruses and coding books
timofeeve [1]
Is there a picture to go along with this? I don’t see one and an willing to help!
3 0
3 years ago
Which of the following views would you use to see your Web page while working on it?
brilliants [131]
D) Alt Tags thats the answer i think
8 0
3 years ago
JavaScript
Mekhanik [1.2K]

Answer:

C. 40

Explanation:

The code uses IF and ELSE statements to carry execute a block of code if any of the statements hold true

OrderTotal here is greater than 100, and this allows the second IF ELSE block to be executed.

The code to be executed is discountAmount = OrderTotal * 0.2

This will be discountAmount = 200 *0.2

therefore, discountAmount = 40.

3 0
3 years ago
Other questions:
  • A company wants to build a webpage that displays KPIs that can be derived from values in datasets stored in Einstein Analytics.
    6·1 answer
  • To move down one paragraph, press the ____ key(s).
    15·1 answer
  • The procedure call mystery(38) will yield which output? __________ a) 0 12 b) 12 0 c) 1 1 0 2 d) 1 1 1 1 e) 2 0 1 1 public void
    11·1 answer
  • When will once upon a time season 6 air
    9·2 answers
  • Which is a correct way to test whether two variables representing numbers, numOne and numTwo, are equal?
    8·1 answer
  • Choose a different well-known company that you know of, and describe its direct and indirect competitors. Describe at least 2 di
    9·2 answers
  • The challenge of preparing for ____________________ is in ensuring that employees do not feel that they are being prepared for t
    7·1 answer
  • What are some ways to rename a worksheet? Check all that apply.
    9·1 answer
  • PLZ HELP!! How does HTML help solve the problem of telling a computer what a web page looks like, not just the content that is o
    15·1 answer
  • an attacker is attempting to crack a system's password by matching the password hash to a hash in a large table of hashes he or
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!