Question: JAVA 2. Dynamic Array (16 points) The current version of the dynamic array in this class only increases its size if needed. Now we want

JAVA

JAVA 2. Dynamic Array (16 points) The current version of the dynamicarray in this class only increases its size if needed. Now we

2. Dynamic Array (16 points) The current version of the dynamic array in this class only increases its size if needed. Now we want the dynamic array also to shrink its size if the array does not have many elements. More specifically, we want the dynamic array to shrink its capacity to half if it is only 1/3 full and its capacity is greater than 1000. For example, if the dynamic array has a capacity of 1000, and the dynamic array is empty, then the dynamic array does not shrink because its capacity is not greater than 1000. If a dynamic array has a capacity of 2000, and the array has 666 elements, then the dynamic array should shrink its capacity to 1000. The original remove method is: String remove(int index) { // assume index is valid String removeValue = this.array[index]; for (int i = index; i

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!