Question: O running lota Favorite Language/Type: Java Array!ntList implementing instance methods Related Links:ArrayIntList,java Author: Stuart Reges (on 2014/02/13) Write a method running Total that returns a

 O running lota Favorite Language/Type: Java Array!ntList implementing instance methods Related

O running lota Favorite Language/Type: Java Array!ntList implementing instance methods Related Links:ArrayIntList,java Author: Stuart Reges (on 2014/02/13) Write a method running Total that returns a new ArraylntList that contains a running total of the original list. In other words, the i-th value in the new list should store the sum of elements 0 through i of the original list. For example, if a variable list stores the following sequence of values [2, 3, 5, 4, 7, 15, 20, 7] and the following call is made Array!ntList list2 = list . runningTotal(); Then the variable list2 should store the following sequence of values [2, 5, 10, 14, 21, 36, 56, 63] The original list should not be changed by the method. The new list should have the same capacity as the original. Remember that there is a constructor for ArraylntList that takes a capacity as a parameter: // pre: capacity -0 // post: constructs an empty list with the given capacity public ArrayIntList(int capacity) If the original list is empty, the result should be an empty list. You are writing a method for the ArraylntList class discussed in lecture (handouts 3 and 5) public class ArrayIntList ( private int[] elementData; // list of integers private int size; // current # of elements in the list You are not to call any ArraylntList methods other than a constructor to solve this problem and your method must run in O(n) time where n is the size of the list. Write your solution to runningTotal below Type vour solution here

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!