Question: Write a method called fromCounts that converts an ArraylntList of counts into a new ArraylntList of values. Assume that the ArraylntList that is called stores

Write a method called fromCounts that converts an ArraylntList of counts into a new ArraylntList of values. Assume that the ArraylntList that is called stores a sequence of integer pairs that each indicate a count and a number. For example, suppose that an ArraylntList called list stores the following sequence of values This sequence of pairs indicates that you have 5 occurrences of 2, followed by two occurrences of -5, followed by 4 occurrences of 3, and so on. If we make the following call ArrayIntList list2 list.fromCounts (); Then the variable list2 should store the following sequence of values [2, 2, 2, 2, 2, -5, -5, 3, 3, 3, 3, 4, 4, 1, 0, 17, 17] You are writing a method for the ArraylntList class discussed in lecture public class ArrayIntList f private int[] elementData; // list of integers private int size; // current # of elements in the list
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
