Module 9 · Arrays
Searching and Frequency Counting
Free with an accountReading
The class votes on the end-of-year trip, and each ballot carries the voter's student number. David hunts for double votes by comparing each ballot with every earlier one. Amara ticks one box per student number instead, and a box already ticked is a double vote.
Checking what this lesson needs for you…
What is inside Searching and Frequency Counting
- Linear search, and why not found is -1
- A count array: the value is the index
- The first double vote, in one pass
- Every pair against one pass, measured
- The sieve of Eratosthenes
- Prefix sums: running totals in one pass