Question bank › A-level Computer Science › Theory of computation

Classification of algorithms, Big-O, halting problem and Turing machines

Answer on paper first, then reveal the mark scheme one mark at a time.

1Standard4 marks

(a) State the time complexity of the following algorithm in terms of n. [1]

FOR i ← 1 TO n
  FOR j ← 1 TO n
    OUTPUT i * j
  ENDFOR
ENDFOR

(b) State the time complexity of a binary search on a sorted list of n items. [1]

(c) An algorithm with time complexity O(n²) takes 4 ms for n = 1000. Estimate the time it takes for n = 3000. Show your working. [2]

2Hard6 marks

A Turing machine has the transition table below. Symbols are 0, 1 and _ (blank). The tape is blank on both sides of the input. The head starts on the leftmost symbol of the input in state q0. H is the halting state. Each rule is (new state, symbol written, direction).

StateRead 0Read 1Read _
q0(q0, 0, R)(q0, 1, R)(q1, _, L)
q1(H, 1, R)(q1, 0, L)(H, 1, R)

(a) The tape initially holds 1011. Give the tape contents when the machine halts. [1]

(b) State what the machine does to the binary number on the tape. [1]

(c) State the number of transitions the machine makes on the input 1011, including the one that enters H. Show your working. [2]

(d) Explain why a Turing machine is a useful model of computation. [2]

3Standard4 marks

(a) State what is meant by the halting problem. [1]

(b) State the significance of the halting problem for computer scientists. [1]

(c) Distinguish between a problem that is intractable and a problem that is unsolvable. [2]

Stuck on this topic?

Book a free 30-minute session on WhatsApp and we'll find exactly which step is costing you the marks. Or build a timed paper on it.

Free 30-minute session