Data Collections unit test
A test on this unit alone, marked as a percentage and a letter grade — for the test your class is actually sitting, rather than for May. Answer everything, then submit once: seeing the answer to question 3 before attempting question 4 makes the final percentage meaningless.
Standard algorithm: shift elements left
Array indexing
Efficiency of insertion into an ArrayList
Array
Swapping two elements
Looping backward to remove safely
ArrayList of objects
Standard algorithm: count elements meeting a condition
Why merge sort is faster on large arrays
2D array
Removing all matching elements
Building a String in a loop
Short answer 1. Define or explain: Comparing objects in a collection
3 ptsShort answer 2. Define or explain: Off-by-one in array bounds
3 ptsShort answer 3. Define or explain: Array of objects
3 ptsShort answer 4. Define or explain: Declaring an ArrayList
3 ptsFree response
9 pts2D ARRAY (Question 4, 9 points). An elevation map is represented by the ElevationMap class, which has a private instance variable int[][] heights. The entry heights[r][c] is the elevation, in meters, at that position. The array is rectangular with at least one row and one column. You will write two ElevationMap methods. public int highestInColumn(int col) — returns the largest elevation in column col. You may assume 0 ≤ col < heights[0].length. public int countPeaks() — returns the number of positions whose elevation is strictly greater than the elevation at every one of its in-bounds neighbors directly above, below, to the left and to the right. Diagonal neighbors are not considered. A position on an edge or corner is compared only with the neighbors that exist. (For example, in the array {{1, 2, 1}, {4, 3, 2}, {1, 5, 1}} the peaks are the 4 at [1][0] — greater than 1 above, 1 below and 3 to the right — and the 5 at [2][1] — greater than 3 above, 1 to the left and 1 to the right — so the method returns 2.)
A. Write method highestInColumn.
B. Write method countPeaks.