Signed up recently but had issues with the confirmation email?
Click Forgot password and follow the reset steps. You can choose the same password you used when you signed up. This should then provide access.
Remember to check Spam and Junk. The email will be from auth@progressbytes.co.uk.
Comparison of the complexity of algorithms.
2.3.1 Algorithms
Practise exam questionsAlgorithms — Note 4 of 6
Candidates need to know the best and worst case complexities for the searching and sorting algorithms. Candidates need to understand the difference between best, average and worst case complexity and why these can differ for an algorithm.
You need to compare the standard searching and sorting algorithms using Big O notation, including their best, average and worst cases, and explain why these can differ.
Algorithm Best Average Worst Extra space
Linear search O(1) O(n) O(n) O(1)
Binary search O(1) O(log n) O(log n) O(1)
Bubble sort O(n) O(n^2) O(n^2) O(1)
Insertion sort O(n) O(n^2) O(n^2) O(1)
Merge sort O(n log n) O(n log n) O(n log n) O(n)
Quick sort O(n log n) O(n log n) O(n^2) O(log n)*
Binary search's O(1) space is for the iterative version; a recursive
version uses O(log n) space for its call stack.
* Quick sort uses O(log n) space on average, up to O(n) in the worst case.The input that makes the algorithm do the least work, e.g. the item being searched for is first in the list.
The input that makes the algorithm do the most work, e.g. the item is last or not present.
The expected work over typical inputs.
Ready to test yourself?
Practise 2.3.1 questions