The chapter in short
An algorithm is a finite, precise sequence of steps to solve a problem. The chapter covers how to design, express and analyse algorithms.
It covers flowcharts and pseudocode, linear and binary search, bubble, selection and insertion sort, and comparing algorithms by their time complexity.
AlgorithmPseudocodeLinear searchBinary searchSortingTime complexity
Key points
- A good algorithm is finite, definite, effective and has input and output.
- Linear search checks items one by one; it works on any list.
- Binary search halves a sorted list each step; it is much faster on large lists.
- Bubble sort repeatedly swaps adjacent items that are out of order.
- Big-O notation describes how running time grows with input size.
- Linear search is O(n); binary search is O(log n).
Definitions
- 1
Algorithm
A finite sequence of well-defined steps that solves a problem.
- 2
Pseudocode
An informal, structured description of an algorithm in plain language.
- 3
Linear search
Searching by checking each element in turn.
- 4
Binary search
Searching a sorted list by repeatedly halving the search range.
- 5
Sorting
Arranging data in a particular order.
- 6
Time complexity
How the running time of an algorithm grows with the size of its input.
Formulas
Complexities
linear search O(n); binary search O(log n); bubble sort O(n²)