Standard algorithms
There are three standard algorithms in the Higher course.
Count occurrences
Loop through an array and count how many items match a condition
- Numbers of “Janes” in the names array
- Number of teenagers in the ages array
Find maximum and minimum
Loop through an array and find the largest or smallest value.
- Find the oldest person in the ages array
- Find the shortest name in the names array
Linear search
Loop through an array to find the position of the search target. This algorithm has two approaches.
- Search for all occurrences in an array
- Search for the first occurence