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.
Sign in to read
This lesson is free, with an account
An account costs nothing and opens every lesson in this track that is not marked Pro, on every device you read on.
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