1. The trimToSize method should handle these cases: (1) If the length of the array is already equal to the number of items, then do no work; (2) if the number of items is zero, then change data to an...


1. The trimToSize method should handle these cases: (1) If the length of the array is already equal to the number of items, then do no work; (2) if the number of items is zero, then change data to an array of capacity zero and return with no other work; (3) if (front<=rear),>rear), then allocate a new array of the correct size and activate System.arraycopy twice to copy the two segments into the new array.


The fourth case is similar to the final case of ensureCapacity. If you copy the items into the front of the new array, then make sure you also change front and rear to reflect the new positions of the items.





Dec 03, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here