Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Fill in the definitions to the three ArrayList utility methods in the ALUtils class which is outlined below and included in the code pack for
Fill in the definitions to the three ArrayList utility methods in the ALUtils class which is outlined below and included in the code pack for this lab. The methods are described adequately via Javadoc comments, and there are examples below.
import java.util.*; public class ALUtils{ /** * Creates and returns a copy of the parameter xs, with all items in the * reversed order. Does not modify the original list. When the parameter * is null, the result is an empty list. * * @param xs the list to create a reversed version * @return the reversed version of the parameter a. */ public staticArrayList reverse(ArrayList xs){ // Your definition here throw new UnsupportedOperationException("unimplemented!"); } /** * Creates and returns copy of the given ArrayList xs, rotating * elements away from the front (and wrapping back in from end to * front) as many times as there is positive shift quantity. When * xs is null, the answer is an empty list. * * @param xs the list from which to create a rotated version * @param shift # spaces each item shifts away from front (when positive) * @return the rotated version of the input list. */ public static ArrayList rotate(ArrayList xs, int shift){ // Your definition here throw new UnsupportedOperationException("unimplemented!"); } /** * Creates and returns a new ArrayList by interleaving elements from the * two parameter ArrayLists. If either list is longer, its extra elements * are preserved at the end of the answer list. The answer's size equals * the sum of the parameter lists' sizes, always. If either list is null, * it is treated like an empty list (contributes no items). The answer is * never null. * * @param xs the first parameter list * @param ys the second parameter list * @return the interlaced combination of the two lists. */ public static ArrayList interlace(ArrayList xs, ArrayList ys){ // Your definition here throw new UnsupportedOperationException("unimplemented!"); } }
Step 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