9618/32 May/June 2022 · Question 8(c) · 3 marks
Compare the performance of the algorithms for a binary search and a linear search using Big O notation for order of time complexity.
Points that gain marks
- Linear search is O(n); binary search is O(log n).
- The time to search increases linearly with the number of items for a linear search, and logarithmically for a binary search.
- The time to search increases less rapidly for a binary search than for a linear search.
In this lab: Levels 1 and 2 run both searches on the same list sizes.