10 questions🇬🇧English

🔀 Sorting Algorithms & Big O – A-level

Computer Science · A-level — practises sorting and searching algorithms and their time complexity in Big O

Make it your own private quiz and change anything you like

Questions

What is the worst-case time complexity of a linear search on a list of n items?

O(n²)
O(1)
O(n)
O(log n)
20s

Which condition must a list meet before a binary search can be used on it?

It must have no repeated values
It must have an even number of items
It must be sorted
It must be stored as a linked list
20s

What is the worst-case time complexity of a binary search on a sorted list of n items?

O(1)
O(n)
O(n log n)
O(log n)
20s

Which list orders these complexities from slowest-growing to fastest-growing?

O(1), O(log n), O(n), O(n log n), O(n²)
O(1), O(n), O(log n), O(n log n), O(n²)
O(1), O(log n), O(n log n), O(n), O(n²)
O(log n), O(1), O(n), O(n²), O(n log n)
30s

An ascending bubble sort is applied to [5, 2, 4, 1]. What is the list after the first complete pass?

[2, 1, 4, 5]
[2, 4, 1, 5]
[1, 2, 4, 5]
[2, 5, 4, 1]
30s

An O(n²) algorithm takes 2 seconds to process 1000 items. Approximately how long will it take for 2000 items?

4 seconds
8 seconds
6 seconds
16 seconds
30s

A bubble sort stops early if a pass makes no swaps. What is its time complexity when given a list that is already sorted?

O(log n)
O(n²)
O(n)
O(n log n)
30s

What is the space complexity of a standard merge sort on an array of n items?

O(1)
O(n)
O(log n)
O(n²)
30s

An ascending insertion sort is applied to [5, 1, 4, 2, 3]. What is the list after the second pass?

[1, 5, 4, 2, 3]
[1, 4, 2, 3, 5]
[1, 2, 4, 5, 3]
[1, 4, 5, 2, 3]
60s

Quick sort usually runs in O(n log n) time. What causes its worst case of O(n²)?

Every item is copied into a new array
The list contains an odd number of items
Each sublist is split exactly in half
The pivot is always the smallest or largest item
30s