Question: nts) Write a method called insertat that takes an index, an inteef intgers (that inserts n copies of the given value astinsertAt(2, 4, 88) will
nts) Write a method called insertat that takes an index, an inteef intgers (that inserts n copies of the given value astinsertAt(2, 4, 88) will change this sequence: ex, an integer n, and a value as at the given index in a list of integers. For example a canl to given (12, 42, 8, 988] to [12, 42, 88, 88, 88, 88, 8, 988) You are writing a method for the A rrayintList class discussed in lecture public class ArrayintList ( private int[l elementData; // list of integers private int size; // current # of elements in the list <...methods> Your method checks less than 0 or greater than the number of ele not to call a the boundary condition and throws an IllegalArgumentException if the index is ments in the list or if the value of n is less than 0. You are ure tho array, ArrayList, etc), and your solution must run in O(n m) time where n is the or items to add and m is the length of the list. You may assume that the array has sufficient ny other ther ArrayintList methods to solve this problem, you are not allowed to define auxiliary data structure (no ay, ArrayLi capacity to store the new values
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
