Week 6 — Arrays
May 4 – May 8 · 6 lessons · Array Statistics & Wordle labs
- 6-a Arrays: A Row of Variables That Share a Name Fixed size, indices from zero, three creation forms
- 6-b Walking an Array (and the Aliasing Trap) Canonical for, off-by-one, accumulators, aliasing
- 6-c Arrays as Method Parameters Reference semantics, mutation, returning a new array
- 6-d Searching Arrays Linear search, the −1 sentinel, binary search
- 6-e Sorting an Array Swap pattern, selection sort, insertion sort, parallel-array anti-pattern
- 6-f Array Tracing & Mystery Strategy Substitute–simplify–lookup, trace tables, live arrays, aliasing puzzles
Objectives
- Declare, allocate, and initialize arrays three different ways
- Walk an array with the canonical for-loop and pick the right accumulator seed
- Predict the effect of passing an array to a method (mutate-in-place vs. return-a-new-array)
- Implement linear search and binary search, and choose between them given the input shape
- Implement selection sort and insertion sort, and trace one outer pass on paper
- Recognize the parallel-array anti-pattern and explain why classes (Week 8) fix it
- Build a trace table for any array-mystery problem, including live writes and aliasing puzzles