Write a recursive function called sum_values that takes in a list of integers and an index of one element in the list and

3 answers
Question:

Write a recursive function called sum_values that takes in a list of integers and an index of one element in the list and returns the sum of all values/elements in the list starting with the element with the provided index and ending with the last element in the list.

Answers

Explanation:

The following code is written in the Java programming language and actually takes in three parameters, the first is the list with all of the int values. The second parameter is the starting point where the adding needs to start. Lastly is the int finalSum which is the variable where the values are all going to be added in order to calculate a final int value. Once the recursive function finishes going through the list it exits the function and prints out the finalSum value.

   public static void sum_Values(ArrayList<Integer> myList, int startingPoint, int finalSum) {

           if (myList.size() == startingPoint) {

               System.out.println(finalSum);

               return;

           } else {

               finalSum += myList.get(startingPoint);

               sum_Values(myList, startingPoint+1, finalSum);

           }

           

   }

you

ill join

we need a link or picture : )

Similar Solved Works

2 answers

Rectangle FGHJ has coordinates F(-8, 6), G(8, 6), H(8,-6), and J(-8, -6). The rectangle is dilated by a scale factor of

Rectangle FGHJ has coordinates F(-8, 6), G(8, 6), H(8,-6), and J(-8, -6). The rectangle is dilated by a scale factor of v with the origin as the center of dilation to form rectangle F'G'H'J'. Which ordered pair represents the coordinates of vertex H'?...
10 answers

What are quadrilateral with no parallel sides

What are quadrilateral with no parallel sides...
3 answers

Differentiate between expansion of solid and liquid​

Differentiate between expansion of solid and liquid​...
10 answers

Ineed cause i dont know this question , to start a tradition for others to follow​

Ineed cause i dont know this question , to start a tradition for others to follow​...
4 answers

Suppose the Fed has decided to buy government securities using open market operations. The goal of this policy is to: g

Suppose the Fed has decided to buy government securities using open market operations. The goal of this policy is to: g...
3 answers

What is the answer to x? Given the top of the triangle is 80.

What is the answer to x? Given the top of the triangle is 80. [tex]What is the answer to x? Given the top of the triangle is 80.[/tex]...
9 answers

What is the area of this triangle?

What is the area of this triangle? [tex]What is the area of this triangle?[/tex]...
12 answers

In which direction would you travel to get from the capital of Australia to the capital of New Zealand.

in which direction would you travel to get from the capital of Australia to the capital of New Zealand....
3 answers

What impact will new classes law have on high schools? ​

What impact will new classes law have on high schools? ​...
4 answers

Why did the us want to overthrow fidel castro when he took control of cuba? question 20 options: castro

Why did the us want to overthrow fidel castro when he took control of cuba? question 20 options: castro was a fugitive from justice in the us castro wanted to annex miami as part of cuba castro would not allow the us to place missile defense system in cuba because he was a communist dictator...
1 answer

Which of the following is indicated by a graph which displays the number of individuals in a population

Which of the following is indicated by a graph which displays the number of individuals in a population in relation with the amount of time passed?...
3 answers

45 which type of equilibrium exists in a sealed flask containing br2(ℓ) and br2(g) at 298 k and 1.0 atm? (1) static phase

45 which type of equilibrium exists in a sealed flask containing br2(ℓ) and br2(g) at 298 k and 1.0 atm? (1) static phase equilibrium (2) static solution equilibrium (3) dynamic phase equilibrium (4) dynamic solution equilibrium...
4 answers

Questlon 3 of 5 Which kind of energy does an object have because of its height above Earth's surface? O A. Electrical O

Questlon 3 of 5 Which kind of energy does an object have because of its height above Earth's surface? O A. Electrical O B. Chemical O C. Elastic D. Gravitational​...
4 answers

Qué tipo de servicios educativos ofrece la ciudad de mar del plata

Qué tipo de servicios educativos ofrece la ciudad de mar del plata...
3 answers

Kiran scored 36 baskets in 1 week. she scored 1/2 of the baskets on the weekend. she

Kiran scored 36 baskets in 1 week. she scored 1/2 of the baskets on the weekend. she scored 1/4 of them on tuesday, she scored 1/12 of them on wednesday and the rest on thursday. how many baskets did kiran score on thursday...
4 answers

An X-Ray shows the dorsal side of a patient. What cavity would NOT be visible on the image A. Cranial

An X-Ray shows the dorsal side of a patient. What cavity would NOT be visible on the image A. Cranial B. Abdominal C. Spinal D. Dorsal...
5 answers

Think about the people of Mexico and what we have learned about the different classes (Upper, middle- and lower-class citizens.) Think about what life

Think about the people of Mexico and what we have learned about the different classes (Upper, middle- and lower-class citizens.) Think about what life is like for many people who live in Mexico, then think different ways that we can be praying for them. List some specific things that you can be in p...
3 answers

Which type of solute does pressure influence solubility the most?

Which type of solute does pressure influence solubility the most?...
3 answers

Amount of something is too small

Amount of something is too small...
4 answers

Determine if the two triangles are congruent. If they are, statethe condition.

Determine if the two triangles are congruent. If they are, state the condition. [tex]Determine if the two triangles are congruent. If they are, state the condition.[/tex]...

-- 0.050554--