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

6 answers

The fundamental frequency of a pipe that is open at both ends is 504 HzHz. Part A How long is this pipe

The fundamental frequency of a pipe that is open at both ends is 504 HzHz. Part A How long is this pipe...
4 answers

Why on earth have done such a thing?

Why on earth have done such a thing?...
4 answers

Suppose a high school student is selected at random. Let event A = junior and event B = fiction. Are

Suppose a high school student is selected at random. Let event A = junior and event B = fiction. Are events A and B independent? Yes, P(A) = P(A|B). Yes, P(A) = P(B|A). No, P(A) ≠ P(A|B). No, P(A) ≠ P(B|A). [tex]Suppose a high school student is selected at random. Let event A = junior ...
5 answers

Art and his friends spent $62 at the movies. admission tickets cost $12 apiece, and a bucket of popcorn

Art and his friends spent $62 at the movies. admission tickets cost $12 apiece, and a bucket of popcorn costs $7. which equation written in standard form represents the number of tickets bought, t, and the number of buckets of popcorn bought, p? a. 12p + 7t = 62 b. 7p + 12t = 62 c. 12p = 62 – 7t...
6 answers

Which was a conservative view of government in Europe during the early nineteenth century?A. The government should protect the freedoms

Which was a conservative view of government in Europe during the early nineteenth century? A. The government should protect the freedoms of individuals. B. The government must act according to the will of the people. C. The government must preserve the power of the monarchy. D. The government s...
3 answers

How long do you have on this section of the act?

How long do you have on this section of the act?...
2 answers

The greatest integer function, shown below, is defined to be the greatestless than or equal to x.fx) = [[x]]​

The greatest integer function, shown below, is defined to be the greatestless than or equal to x.fx) = [[x]]​...
6 answers

In the diagram, which represents a catalyst?

In the diagram, which represents a catalyst?...
4 answers

Walt whitman is known for his imagery. true false

Walt whitman is known for his imagery. true false...
4 answers

What is the value of 12 (8 + 9)?105204357864

What is the value of 12 (8 + 9)? 105 204 357 864...
3 answers

•what kind of reinforcement should a parent use to ensure that their child would continue to clean

•what kind of reinforcement should a parent use to ensure that their child would continue to clean his room once he has started doing it?...
4 answers

Why is machu picchu of great archaeological importance? a. it was undisturbed since inka times b. it

Why is machu picchu of great archaeological importance? a. it was undisturbed since inka times b. it was the most excavated site following its discovery in the late 1800s. c. its extensive written records detailed the city’s history as a private compound for the inka. d. the history of its conque...
3 answers

What is a stanza? And how are ways they help the reader understand poems?

What is a stanza? And how are ways they help the reader understand poems?...
4 answers

Many dialects are considered nonstandard english.

Many dialects are considered nonstandard english....
3 answers

What was the impact of the 9-11 attacks on presidential power?

What was the impact of the 9-11 attacks on presidential power?...
4 answers

Is there any one from michigan?

Is there any one from michigan?...
3 answers

Someone plz help me I will give brainliest

Someone plz help me I will give brainliest [tex]Someone plz help me I will give brainliest[/tex]...
4 answers

The perimeter of a rectangular painting is 284 centimeters. The length is 18 centimeters more than the

The perimeter of a rectangular painting is 284 centimeters. The length is 18 centimeters more than the width. Find the length and width( in cm)...
3 answers

25 POINTSA hockey player strikes a hockey puck. The height of the puck increases until it reaches

25 POINTS A hockey player strikes a hockey puck. The height of the puck increases until it reaches a maximum height of 3 feet, 55 feet away from the player. The height y (in feet) of a second hockey puck is modeled by y=x(0.15−0.001x), where x is the horizontal distance (in feet). Compare the dis...
3 answers

What percentage of sheep’s had a body height of 1.2 meters or more 30 year ago?

What percentage of sheep’s had a body height of 1.2 meters or more 30 year ago?...

-- 0.017882--