CSC 183 · Introduction to Problem Solving
Our notes
2 min readSolvable 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
-
Best pick Introduction to Computer Science, 3.5 Sample Algorithms by Problem
(opens openstax.org in a new tab)
OpenStax, Introduction to Computer Science, 3.5 Sample Algorithms by Problem, CC BY-NC-SA 4.0 · licence
-
Halting problem
(opens en.wikipedia.org in a new tab)
Wikipedia, Halting problem, CC BY-SA 4.0 · licence
-
Travelling salesman problem
(opens en.wikipedia.org in a new tab)
Wikipedia, Travelling salesman problem, CC BY-SA 4.0 · licence
-
OpenStax, Introduction to Computer Science (whole free textbook)
The whole book, free to read online or download as a PDF (the PDF is large: Wi-Fi).
(opens openstax.org in a new tab)
OpenStax, OpenStax, Introduction to Computer Science (whole free textbook), CC BY-NC-SA 4.0 · licence
Watch
-
Decidable vs. Undecidable Problems in Algorithms
10 min · ≈ 45 MB · about ₦25
(opens youtube.com in a new tab)
-
The greatest unsolved problem in computer science...
7 min · ≈ 32 MB · about ₦18
(opens youtube.com in a new tab)
-
Solvable and unsolvable problems with examples | First year computer science
4 min · ≈ 18 MB · about ₦10
(opens youtube.com in a new tab)
-
Solvable Vs Unsolvable Problems - 11th Class (1st Year) Computer Science
10 min · ≈ 45 MB · about ₦25
(opens youtube.com in a new tab)
-
Solvable and Unsolvable Problems with Examples for ICS
15 min · ≈ 68 MB · about ₦38
(opens youtube.com in a new tab)
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.