Compatibility: Although written in Python 2.7, these Python files should be fully compatible with Python 3.
This is a complete set of Python examples for the current A-Level Algorithms specification, excluding examples for path finding algorithms which may be added at a later stage. Below is a list of the included algorithms and their corresponding orders (Big O):
- Sequential/Linear Search – O(n)
- Binary Search – O(logn)
- Hash Tables – O(1) depending on collision response strategy
- Insertion Sort – O(n^2) worst case
- Bubble Sort – O(n^2) worst case
- Merge Sort – O(nlogn) best case
- Quick Sort – O(nlogn) best case
For each of the algorithms there is at least one of the below code examples:
- Base Algorithm – This file is a basic implementation of the algorithm, showing students how the technique works. The code contains no comments and is designed to allow students opportunity to work out what the algorithm is doing.
- Base Algorithm with comments – This file extends on the basic algorithm program by adding detailed comments on what is happening.
- Base Algorithm with output – This file extends the algorithm by including detailed output in the console to show what is happening at each individual stage of the algorithm.
- Base Algorithm with comparisons – This file counts the number of comparisons that are made whilst the algorithm is running to allow students to estimate the order (Big O) of the algorithm
- Base Algorithm incomplete – This is a skeleton code file that has sections of the code missing, allowing students to try and devise their own logical solution to the merge sort problem.
As with any resource, this list is neither exhaustive nor complete and as time progresses the files contained within this example code repository will be updated and extended, available to re-download free of charge.