Definitions - Component 2.3 Algorithms - OCR Computer Science A-Level
Definitions - Component 2.3 Algorithms - OCR Computer Science A-Level
2.3.1 Algorithms
Binary Search: A O(log(n)) algorithm to search a sorted list for a particular item by
repeatedly halving the sublist which could contain the item.
Breadth-First Traversal : A method of traversing a graph by using a queue to visit all the
neighbours of the current node before doing the same to each of the neighbours until the
entire graph has been explored.
Bubble Sort: A O(n 2) sorting algorithm that iterates through a list, comparing each element
to its successor and swapping elements if the successor is greater than the current element.
This is repeated until no more swaps can be made.
Depth-First Traversal: A method of traversing a graph by using a stack to travel as far along
one route as possible and then backtracking and doing the same for the remaining routes
until the entire graph has been explored.
Dijkstra’s Shortest Path Algorithm: An algorithm to find the shortest path between two
nodes on a graph by using a priority queue to keep track of the shortest distance (cost) to
each node from the starting node until the destination node is found.
Insertion Sort: A O(n 2) sorting algorithm that divides a list into a sorted and unsorted
section. Elements from the unsorted section are compared with and placed in the right
position in the sorted section one by one until the sorted section spans the entire list.
Linear Search: A O(n) algorithm to search a list for a particular item by iterating through the
list and checking each element until the required item is located, or the end of the list is
reached.
Merge Sort: A O(n log(n)) divide-and-conquer sorting algorithm that recursively halves the
list into sublists until all sublists are of length 1. The sublists are then merged back together
This work by PMT Education is licensed under https://bit.ly/pmt-cc
https://bit.ly/pmt-edu-cc CC BY-NC-ND 4.0
https://bit.ly/pmt-cc
https://bit.ly/pmt-edu https://bit.ly/pmt-cc
in such a way that they are always sorted, until the full single list is obtained.
O(1) (Constant time/space): An algorithm that always takes a constant amount of time or
memory space to execute, regardless of the input size.
O(n) (Linear time/space): An algorithm whose execution time or required memory space is
directly proportional to the size of its input.
Quick Sort: A O(n log(n)) sorting algorithm similar to Merge Sort, but relies on choosing a
pivot element whenever the list is split. Elements greater than the pivot go into one sub list,
while the rest go into the other. All sublists of length 1 will already be in a sorted order.
https://bit.ly/pmt-cc
https://bit.ly/pmt-edu https://bit.ly/pmt-cc