AP CSP Topic 3.18: Undecidable Problems | Big Idea 3 | APCSExamPrep.com
Topic 3.18: Undecidable Problems
🎯 Learning Objectives
- Define what it means for a problem to be undecidable
- Explain the halting problem and why no general solution exists
- Distinguish undecidable from merely difficult (unreasonable efficiency)
- Recognize the limits of what computing can and cannot accomplish
Can a program check any other program for infinite loops and always give the right answer? Mathematicians proved in 1936 that it's impossible -- not because we haven't found the algorithm yet, but because no such algorithm can exist. Ever.
What Is an Undecidable Problem?
A decidable problem has an algorithm that always gives a correct yes/no answer in finite time. An undecidable problem cannot -- no algorithm exists that correctly answers all possible instances.
Undecidable is different from inefficient. An inefficient problem CAN be solved; it just takes a long time. An undecidable problem CANNOT be solved by any algorithm.
# We CANNOT write this correctly for all inputs:
def will_halt(program, input):
# No algorithm can always return
# True or False correctly here.
# This is the Halting Problem.
pass{The halting problem asks:}
{Given any program P and input I,}
{will P eventually stop?}
{No algorithm can answer this}
{for ALL possible programs.}
{It is undecidable.}The Halting Problem
Alan Turing proved in 1936 that no algorithm can determine, for every possible program and input, whether the program will halt or run forever. The proof uses a contradiction: assume a halting-checker H exists. Build a program P that does the opposite of what H predicts. P breaks H. Therefore H cannot exist.
AP exam point: The halting problem shows computing has fundamental mathematical limits. Some problems are not just hard -- they are provably impossible.
Practice Problems
I. Efficiency problems are solvable given time; undecidable problems cannot be solved at all
II. The halting problem has been proven mathematically impossible, not just slow
III. Given infinite time, all programs produce an answer
decidable if a primality-checking function for any number can exist. Expected: decidable
undecidable to reflect the classification of the general halting problem. Expected: undecidable
efficiency_problem or undecidable describes a problem solvable in 2^n steps. Expected: efficiency_problem
Frequently Asked Questions
🔗 Continue Studying
Get in Touch
Whether you're a student, parent, or teacher — I'd love to hear from you.
Just want free AP CS resources?
Enter your email below and check the subscribe box — no message needed. Students get daily practice questions and study tips. Teachers get curriculum resources and teaching strategies.
Message Sent!
Thanks for reaching out. I'll get back to you within 24 hours.
Prefer email? Reach me directly at [email protected]