Перейти к содержанию

Labs · 9618 A2 19.1

Big O

Run searches and sorts on longer and longer lists and count the comparisons. See what happens when n doubles, predict the count for a bigger list, and name the Big O.

6 levelsFree bench

In the exam

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.

9618/31 May/June 2024 · Question 10(c) · 2 marks

Describe the performance of a binary search in relation to the number of data items in the array being searched. Refer to Big O notation in your answer.

Points that gain marks

  • Binary search is O(log n): Big O shows the time complexity of an algorithm.
  • The time taken increases logarithmically as the number of items increases linearly.
  • Because the part still to search keeps halving, the number of comparisons stays small.

In this lab: Level 2: doubling n adds just one comparison.

9618/31 October/November 2022 · Question 12(b)(i) · 1 marks

State the Big O notation for time complexity of a linear search.

Points that gain marks

  • O(n).

In this lab: Level 1.

More real experiments

Войти или создать аккаунт

IGCSE, A-Level & AP