UNIHIVE

Study Hub UNIPORT CSC 183

CSC 183 · Introduction to Problem Solving

Solvable and unsolvable problems

Problems no algorithm can solve, problems that take too long, and when heuristics are used instead.

Our notes

2 min read

Solvable problems

A problem is solvable (computable) if some algorithm solves every case of it in a finite time: adding numbers, sorting, finding a path through a maze.

Unsolvable problems

Some problems have no algorithm at all, however fast the computer.

  • The halting problem (Alan Turing, 1936): no program can look at every other program and its input and always decide correctly whether it will eventually stop or run forever.

Outline of the idea: suppose a perfect checker H existed. Build a program Q that asks H about itself and then does the opposite (loops forever if H says "stops", stops if H says "loops"). Whatever H answers about Q is wrong. So H cannot exist.

This is why no tool can find every bug that makes a program hang.

Solvable but impractical (intractable)

Some problems have algorithms that take far too long as the input grows.

  • Travelling salesperson: visit n towns once each by the shortest route. Checking every route means (n − 1)! ÷ 2 routes.

Worked example

  • 5 towns: 4! ÷ 2 = 24 ÷ 2 = 12 routes. Easy.
  • 10 towns: 9! ÷ 2 = 362,880 ÷ 2 = 181,440 routes. Still easy for a computer.
  • 20 towns: 19! ÷ 2 ≈ 6.1 × 10¹⁶ routes. At a billion routes a second that is about 2 years.
  • 30 towns: about 4.4 × 10³⁰ routes: far longer than the age of the universe.

Timetabling, delivery routes and packing problems behave like this.

What we do instead

  • Heuristics: fast rules that usually give a good answer. For the salesperson: "always go to the nearest town not yet visited". Not always the best route, but quick and often close.
  • Approximation algorithms: guaranteed to be within some percentage of the best.
  • Restricting the problem: solve small or special cases exactly.

Undecidable versus "we don't know yet"

Some problems are not proved unsolvable; we simply have no fast algorithm yet. Whether a fast algorithm exists for the travelling salesperson problem is the famous open question "P versus NP".

Exams usually ask

  • Distinguish solvable, unsolvable and intractable problems with examples.
  • Explain why heuristics are used.

Common mistake

Thinking a faster computer can solve any problem. Speed does not help an unsolvable problem, and helps very little with an intractable one.

Written by the UniHive team in our own words. Spotted a mistake? Tell us on WhatsApp.

Read

Watch

We link to free material and never copy it. Every link was opened by our team before it went up; video data is a rough guide at 360p.

All CSC 183 topics

Report

Sign in to report this. It is free.

Is this your work (a lecturer, author or publisher)? Ask us to take it down.