Shift Right to Insert at an Index
easyQuestion 556To put a value in the middle of an array, everything from that position onward has to move one slot to the right first. The shift starts at the back, because copying from the front would overwrite a value before it has been moved. size is the number of slots in use (the array data may be longer). The bounds check and the call to grow() are already written, so the slot at index size is always free when your code runs.
Requirements:
1. insertAt(int index, int value) moves the values at index and after it one slot to the right, stores value at index, and raises size by one.
2. index may equal size. Nothing needs to move then, and the value lands at the end.
3. Keep the given check that returns false for an index that is negative or greater than size, and keep the final return true.
Do NOT write a main method.
Expected output
true [10, 20, 30, 40] true [5, 10, 20, 30, 40] true [5, 10, 20, 30, 40, 50] 6 of 8
= newline. The output ends with a newline, so print one after the last line.
Your output
Run your code to see the output here...