Would Write Body Insert Deleteat Delete Locate Methods Ve Tried Writing Code T Seem Get Wo Q43904602
How would we write the body for the insert(), deleteAt(),delete(), and the locate() methods? I’ve tried writing down somecode but can’t seem to get it to work.
* This class provides a growable array for primitive long values. * @author * @version 1.0 1/16/2020 */ class BigIntArrayList { //fields private long[] list; private int count; * Constructor. Initializes the underlying array to 10 elements. */ BigIntArrayList() { list = new long[10]; count = 0; Inserts the given long value at the given index. The index is assumed to be a value between 0 and count. Existing elements are moved up as needed to make room for the new value. * @param index the index where the new value should be stored * @param value the value to be stored */ public void insert(int index, long value) { count = list.length; count++; for (int i = count – 1; i > index; i–) { list[i] = list[i – 1]; list[index] = value; * Deletes the value at the given index. The index is * assumed to be a value between 0 and count – 1. Existing elements are moved down as needed to keep all values contiguous, without any empty spaces in the array. * @param index the index of the element that should be removed * @return the value that was removed */ public long deleteAt (int index) { long[] newList = new long[list.length – 1]; for (int i = 0; i < newList.length; i++) { newList[i] = list[i]; return 0; * Deletes the first instance of the given value. Existing elements * are moved down as needed to keep all values contiguous, without * any empty spaces in the array. If the value does not exist, this * method returns without doing anything. * @param value the value to remove public void delete (long value) { //TODO complete this method * Returns the value at the given index without removing it. The index is * assumed to be a value between 0 and count – 1. * @param index the index of the element * @return the value at that index public long getValueAt (int index) { //TODO complete this method return 0; //replace this return statement * Returns the index of the first instance of the given value * in the array. If the value doesn’t exist, -1 is returned. * @param value the value to find in the array * @return the index where the value was found, or -1 if not found public int locate (long value) { int index = -1; for (int i = 0; i < list.length; i++) { if (list[i] == value) { index = i; return index; * Provides access to the number of values currently in the array. * @return the number of values in the array */ public int getCount() { return count; Show transcribed image text * This class provides a growable array for primitive long values. * @author * @version 1.0 1/16/2020 */ class BigIntArrayList { //fields private long[] list; private int count; * Constructor. Initializes the underlying array to 10 elements. */ BigIntArrayList() { list = new long[10]; count = 0; Inserts the given long value at the given index. The index is assumed to be a value between 0 and count. Existing elements are moved up as needed to make room for the new value. * @param index the index where the new value should be stored * @param value the value to be stored */ public void insert(int index, long value) { count = list.length; count++; for (int i = count – 1; i > index; i–) { list[i] = list[i – 1]; list[index] = value; * Deletes the value at the given index. The index is * assumed to be a value between 0 and count – 1. Existing elements are moved down as needed to keep all values contiguous, without any empty spaces in the array. * @param index the index of the element that should be removed * @return the value that was removed */ public long deleteAt (int index) { long[] newList = new long[list.length – 1]; for (int i = 0; i
Expert Answer
Answer to How would we write the body for the insert(), deleteAt(), delete(), and the locate() methods? I’ve tried writing down so…
OR