Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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; iStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started