/* * Hw5pr3.java * * Login: * * Complete the methods below and test them using the JUnit test cases in * Hw5pr3Test.java * * Before you submit your file, update this list for the graders as you get * your code working * * *** Methods passing all test cases *** * * * *** Methods not passing all test cases *** * makeArrayOfSameSize * makeArrayWithSameContents * rest * cons * append * merge * insert */ public class Hw5pr3 { /* * makeArrayOfSameSize(int[] src) * * @param src - an array with a non-zero length. * * @return a new array with exactly the same length as the input array but * without any of the content of the input array. */ public static int[] makeArrayOfSameSize(int[] src) { return null; // TODO: write code here! } /* * makeArrayWithSameContents(int[] src) * * @param src - an array with a non-zero length. * * @return a new array with exactly the same length as the input array and * the value at each index in the output array should be identical to the * value at that index in the input array (src). */ public static int[] makeArrayWithSameContents(int[] src) { return null; // TODO: write code here! } /* * rest(int[] src) * * @param src - an array with a length of 2 or greater. * * @return a new array with a length one smaller than the input array and * the value at each index of the output array should be identical to the * value at that index+1 from the input array (src). */ public static int[] rest(int[] src) { return null; // TODO: write code here! } /* * cons(int F, int[] src) * * @param F - the element to add as the element at index 0 in the new array. * * @param src - an array with a non-zero length. * * @return a new array one element longer than the input array. The first * element in the output array should be the int F. The value at each index * in the output array should be identical to the value at that index-1 in * the input array (src). */ public static int[] cons(int F, int[] src) { return null; // TODO: write code here! } /* * append(int[] arr1, int[] arr2) * * @param arr1 - an array with a non-zero length. * * @param arr2 - an array with a non-zero length. * * @return a new array with the elements from arr1 followed by the elements * from arr2. The total length of the output array should be the length of * arr1 plus the length of arr2. */ public static int[] append(int[] arr1, int[] arr2) { return null; // TODO: write code here! } /* * merge(int[] arr1, int[] arr2) * * This method should run in O(arr1.length + arr2.length) so you should not * call a sort method. * * @param arr1 - an array with a non-zero length already in sorted order. * * @param arr2 - an array with a non-zero length already in sorted order. * * @return a new array with all of the elements from both arr1 and arr2 in * sorted order from small to large. The total length of the output array * should be the length of arr1 plus the length of arr2. */ public static int[] merge(int[] arr1, int[] arr2) { return null; // TODO: write code here! } /* * insert(int e, int[] nums) * * This method should run in O(nums.length) so you should not call a sort * method. * * @param e - the element to add the array. * * @param nums - a sorted array with a non-zero length. * * @return a new array one element longer than the input array. The output * array should include the element e and all of the elements from nums. The * output array should be in sorted order from small to large. */ public static int[] insert(int e, int[] nums) { return null; // TODO: write code here! } }