How are problems and algorithms classified by how hard they are to solve?
Understand tractable and intractable problems, the classes P and NP, the idea of computable and non-computable problems, and the use of heuristics for intractable problems.
A focused answer to AQA A-Level Computer Science 4.4.6 and 4.4.7, covering tractable and intractable problems, the classes P and NP, computable and non-computable problems, and the use of heuristics to tackle intractable problems.
Reviewed by: AI editorial process; not yet individually human-reviewed
Have a quick question? Jump to the Q&A page
Jump to a section
What this dot point is asking
AQA wants you to classify problems as tractable or intractable, explain the classes P and NP, distinguish computable from non-computable problems, and explain why heuristics are used for intractable problems.
Tractable and intractable problems
The travelling salesperson problem (visiting every city by the shortest route) is the classic intractable example. The reason intractability bites is the explosive growth of these functions: an algorithm that handles 30 items in seconds would take longer than the age of the universe for a few hundred, so no faster hardware can rescue it. This directly builds on the orders of growth from Big-O complexity, where the gap between polynomial and exponential growth is first quantified.
P and NP
The distinction between solving and verifying is the heart of P versus NP. Many important problems are easy to check but seem hard to solve: given a proposed route for the travelling salesperson, you can quickly add up its length and check it is under a limit (verification), yet finding the shortest route in the first place appears to need exponential effort (solution). If it turned out that P equals NP, every such quickly-checkable problem would also be quickly solvable, which would transform fields from cryptography to logistics, and is why the question is so significant.
Computable problems and heuristics
It is important to keep three categories separate. Non-computable problems cannot be solved by any algorithm ever (the halting problem, decided by Turing). Intractable problems can be solved but not quickly for large inputs. Tractable problems can be solved quickly. Heuristics are the pragmatic response to the middle category: rather than abandon an intractable problem, we settle for a fast approximation that is usually close to optimal, which is why real satnavs and timetabling systems use heuristics rather than exhaustive search.
Exam-style practice questions
Practice questions written in the style of AQA exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.
AQA 20194 marksExplain the difference between a tractable and an intractable problem, and explain why a heuristic might be used to tackle an intractable problem such as the travelling salesperson problem.Show worked answer →
A tractable problem can be solved by an algorithm that runs in polynomial time, such as or , so it remains practical even for large inputs. An intractable problem has a solution in theory but no known polynomial-time algorithm; the best-known algorithms grow far faster (for example or ), so the running time becomes impossibly long as the input grows.
The travelling salesperson problem (finding the shortest route visiting every city) is intractable, so for many cities an exact solution cannot be found in reasonable time. A heuristic is used instead: a rule-of-thumb method (such as always going to the nearest unvisited city) that finds a good-enough, near-optimal route quickly, accepting that it may not be the absolute best.
Markers reward the polynomial versus no-known-polynomial distinction and explaining that a heuristic trades guaranteed optimality for a fast, good-enough answer.
AQA 20214 marksExplain the difference between an intractable problem and a non-computable problem, and describe the relationship between the complexity classes P and NP.Show worked answer →
An intractable problem is solvable in principle but has no known algorithm that runs in reasonable (polynomial) time, so it is impractical for large inputs. A non-computable problem has no algorithmic solution at all, regardless of how much time is available; the halting problem is the classic example. The key difference is that an intractable problem can be solved (just too slowly), whereas a non-computable one can never be solved by any algorithm.
Class P is the set of problems that can be solved in polynomial time. Class NP is the set of problems whose proposed solution can be verified in polynomial time. Every problem in P is also in NP (if you can solve it quickly you can check it quickly). Whether P equals NP, that is whether every quickly-checkable problem is also quickly solvable, is a famous open question.
Markers reward the solvable-but-slow versus no-algorithm distinction and a correct account of P (solvable in polynomial time) and NP (verifiable in polynomial time) with P being a subset of NP.
Related dot points
- Understand Big-O notation for time and space complexity, the common orders of growth, how to determine the complexity of an algorithm, and the meaning of best, average and worst case.
A focused answer to AQA A-Level Computer Science 4.3.5, covering Big-O notation for time and space complexity, the common orders of growth, determining the complexity of an algorithm, and best, average and worst case.
- Understand the Turing machine model, its components, the idea of a universal Turing machine, and the link to the limits of computation and the halting problem.
A focused answer to AQA A-Level Computer Science 4.4.5, covering the Turing machine model and its components, the transition rules, the universal Turing machine, and its link to computability and the halting problem.
- Understand regular expressions and regular languages, the link between regular expressions and finite state machines, the limits of regular languages, and context-free languages described by a BNF grammar.
A focused answer to AQA A-Level Computer Science 4.4.3 and 4.4.4, covering regular expressions and regular languages, their link to finite state machines, the limits of regular languages, and context-free languages described using BNF.
- Understand abstraction, the different forms of abstraction, decomposition, automation, and the components of computational thinking used to solve problems.
A focused answer to AQA A-Level Computer Science 4.4.1, covering abstraction and its forms, decomposition, automation, and the components of computational thinking used to solve problems with computers.
- Understand Dijkstra's shortest path algorithm, how it finds the lowest-cost path from a start vertex, the role of a priority queue, and its applications.
A focused answer to AQA A-Level Computer Science 4.3.4, covering Dijkstra's shortest path algorithm, how it finds the lowest-cost path from a start vertex in a weighted graph, the role of a priority queue, and its applications.
Sources & how we know this
- AQA A-level Computer Science (7517) specification — AQA (2015)