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
You have a combination lock with three secret digits. Find the three correct digits using the following clues and enter your ans
denis-greek [22]

Answer:

021

Explanation:

021 could be your answer

6 0
3 years ago
What is the quotient of 8.16 ÷ 100​
Natalka [10]

Answer:

0.0816

Explanation:

8.16 ÷ 100 = 0.0816 (Ans)

6 0
3 years ago
The ____ is the ranking executive on-site when the crisis or emergency arises, who is authorized to initiate the CM plan.
aleksklad [387]

The answer is the Executive-in charge

The concept of an Executive-in charge came from the military’s chain of command. A chain of command ranges from a supervisor to the top executive of the organization. When a crisis arises, it is possible that one or more of the senior top managers may not be available for consultations because of the travel-intensive positions.






7 0
3 years ago
Read 2 more answers
How drone technology can impact recreation and entertainment​
Maurinko [17]

Drones are become more advanced than ever before. Are now, they are starting to impact recreation. They are small, light, and can maneuver incredibly fast. They are being used in movies, skits, short films, and even high-end videos. Here are some ways drones are changing entertainment:

- Providing high-quality filming, even from 200 feet in the air.

- Reaching spaces where bulky helicopters cannot fit into safely

- Laser shows, where drones shine lights and lasers.

Right now, if you tried to hold your phone still to capture a video, you would not be able to do it. Upon checking the footage, you would see the camera shaking, even if it's just tiny bit. While you can lean it on a surface to fix this, it simply cannot be done in the air to capture. Not to worry, though, you've got drones. They can shoot a steady shot 200 feet in the air. The only thing that could rival drones are expensive, bulky choppers. The drones are cheaper and are mass produced.

However, drones are not only being used to filming movies and films. They are also being used for a different kind of entertainment: Shows. Drones move in formation and shine lights in the night sky, like we saw in the Winter Olympics. They are truly stunning(pics attached).

7 0
2 years ago
Slack space most commonly contains visible data. True or false?
Ivanshal [37]
That is so True because slack space mostly has visible dada
7 0
3 years ago
Other questions:
  • Social networking sites like Office Online, PayPal, and Dropbox are used to develop social and business contacts.
    6·2 answers
  • CHKDSK is a system utility that is commonly found in Windows. What is CHKDSK? Use the Internet to research and write about CHKDS
    15·2 answers
  • What are some programs that you have used that have condition-controlled loops and count-controlled loops?
    10·1 answer
  • Ann wants to save her presentation so she can work on it later. Which device on her computer can store this data long term?
    14·1 answer
  • Which process centers the spreadsheet's content on the page?
    15·1 answer
  • Write a function that accepts an argument for a persons name. The method should loop through the number of characters in the nam
    7·1 answer
  • Asymmetric key encryption combined with the information provided by a. certificate authority allows unique identification of the
    8·1 answer
  • Compound conditions require a computer to sense whether multiple conditions are true or false.
    9·1 answer
  • What is a computer network?
    7·1 answer
  • Match the Job description with the job titles.
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!