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.
array.length
Building a String in a loop
Tracing a sorting question
Traversing part of a collection
Array parameter mutation
Standard algorithm: copy an array
Merging two sorted halves
Initializing an ArrayList with values
Comparing objects in a collection
Traversing an array with an indexed for loop
ArrayList
Nested collection traversal cost
Short answer 1. Define or explain: Declaring an ArrayList
3 ptsShort answer 2. Define or explain: Enhanced for loop over a 2D array
3 ptsShort answer 3. Define or explain: Off-by-one in array bounds
3 ptsShort answer 4. Define or explain: Array initializer list
3 ptsFree response
4 ptsThis course has no free-response prompt tagged to this unit, so one from elsewhere in the course is used. It is still worth writing — the skill transfers.
Write a method `findLongestStreak(int[] arr)` that takes an array of integers and returns the length of the longest consecutive sequence of identical numbers. For example, if arr is {1, 2, 2, 2, 3, 3, 1}, the method should return 3.