SLIDE 1
2001 1
✬ ✫ ✩ ✪
Notes on the Complexity
- f Algorithms
Professor Cristian S. Calude Email: cristian@cs.auckland.ac.nz
2001 2
✬ ✫ ✩ ✪
The Halting Problem
- Theorem. There is no algorithm for deciding
whether a computer program ever halts. Information-theoretic proof. Without restricting the generality assume that all programs incorporate inputs – which are coded as natural
- numbers. So, a program may run forever or may
just eventually stop, in which case it prints a natural number.
2001 3
✬ ✫ ✩ ✪ Assume that there exists a halting program deciding whether an arbitrary program will ever halt. Construct the following program:
- 1. read a natural N;
- 2. generate all programs up to N bits in
size;
- 3. use the halting program to check for
each generated program whether it halts;
- 4. simulate the running of the above
generated programs, and
- 5. output the double of the biggest value
- utput by these programs.
2001 4
✬ ✫ ✩ ✪ The above program halts for every natural N. How long is it? It is about log N bits. Reason: to know N we need log2 N bits (in binary); the rest
- f the program is a constant, so our program is
log N + O(1) bits. Observe that there is a big difference between the size – in bits – of our program and the size of the
- utput produced by this program. Indeed, for large