Question: /** * * all functions must be completed using the instance variable array (data). * it's an array of arrays of integers. * * for
/** * * all functions must be completed using the instance variable array (data). * it's an array of arrays of integers. * * for example: * * int[][] example1 = new int[2][3]; * * results in an array containing 2 sub-arrays, each containing 3 integers each. * * int[][] example2 = {{10,20},{40,50},{70,80}}; * * results in an array containing 3 sub-arrays - * first being {10, 20}, second begin {40, 50}, third being {70, 80} * * int[][] example3 = {{10,20,30},{40},null,{},{70,80}}; * * results in an array containing 5 sub-arrays - * first being {10, 20, 30}, second begin {40}, third being null, fourth being empty and fifth being {70, 80} * * You can traverse an array of arrays (i hate the term 2-dimensional) as: * * for(int i=0; i < example3.length; i++) { //for each sub-array * if(data[i] != null) { //ONLY if current sub-array is not null * for(int k=0; k < example3[i].length; k++) { //for each item in sub-array at index i * //data[i][k] gives sub-array i, item k * } * } * } * */ public class Analytics { public int[][] data;
/** * Populating the array - DO NOT MODIFY * @param source */ public Analytics(int[][] source) { data = source; }
/** * * @return number of sub-arrays */ public int size() { return data.length; } /** * * @param idx * @return true if a sub-array exists at given index (idx), false otherwise. * * SOME EXAMPLES: * if idx = -1, return false since data[-1] is out of bounds * if idx = 0, return true since data[0] refers to the first sub-array * if idx = 1, return true since data[1] refers to the second sub-array * ... * if idx = data.length - 1, return true since data[data.length - 1] refers to the last sub-array * if idx = data.length, return false since data[data.length] is out of bounds */ public boolean isValidSubsetIndex(int idx) { return true; }
/** * * @param idx1 index of sub-array * @param idx2 index of item within the sub-array * @return true if an item exists at sub-array at index idx1 and * at index idx2 within that sub-array, false otherwise */ public boolean itemExistsAt(int idx1, int idx2) { return true; }
/** * * @param idx index of the sub-array whose size is required * @return the number of items in the sub-array at passed index (idx) * if idx = 0, we want the size of the first sub-array * if idx = 1, we want the size of the second sub-array * ... * if the index passed is invalid, return 0 */ public int subsetSize(int idx) { return 0; }
/** * * @param idx * @return sum of all items in sub-array at index idx * return 0 if index is invalid */ public int sum(int idx) { return 0; }
/** * * @param idx * @return average of items in sub-array at index idx * return 0 if index is invalid */ public double subsetAverage(int idx) { return 0; }
/** * * @param idx * @return maximum value in sub-array at index idx * return 0 if index is invalid or if sub-array empty */ public int subsetMax(int idx) { return 0; }
/** * * @param idx * @return maximum value for the passed index within all sub-arrays. * for example, * if idx = 2, you need to return maximum of * data[0][2], data[1][2], ...data[data.length - 1][2] * * * if idx = 5, you need to return maximum of * data[0][5], data[1][5], ...data[data.length - 1][5] * * If an item at the given index does not exist in a specific sub-array, * you should ignore and continue with the remaining sub-arrays. * * If an item at the given index does not exist in ANY sub-array, * you should return 0. */ public int maxForRound(int idx) { return 0; }
/** * * @return highest value in the entire array * return 0 if it's an empty array; like {{},{},{}} */ public int overallMax() { return 0; }
/** * * @return the array converted to a single-dimensional array * For example, * if data = {{10, 40}, {50}, {}, {70, 20, 90}, {}}, * return {10, 40, 50, 70, 20, 90} */ public int[] merge() { return new int[0]; }
https://www.chegg.com/homework-help/questions-and-answers/import-static-orgjunitjupiterapiassertions-import-javaio-import-javalangreflectmethod-impo-q70142025
https://www.chegg.com/homework-help/questions-and-answers/test-order-5-graded-description-testisvalidsubsetindexp-marks-25-public-void-testisvalidsu-q70142167
https://www.chegg.com/homework-help/questions-and-answers/test-order-13-graded-description-testsubsetsizep-marks-25-public-void-testsubsetsizep-asse-q70142265
https://www.chegg.com/homework-help/questions-and-answers/test-order-25-graded-description-testsubsetmaxp-marks-25-public-void-testsubsetmaxp-assert-q70142450
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
