CSCI 150, Spring 2003
Home | | Course Schedule | | Assignments | | Lecture Notes
Program Execution Time
The time a program takes to execute can be important as the problem
sizes grow large and the problems more complex. Examples of such problems
might be:
Tractable problems can run in a reasonable amount of time (e.g. hours or days) for even very large amounts of input data (e.g. millions).
Intractable problems require huge amounts of time (e.g. centuries) for even modest input sizes (e.g. tens or hundreds of inputs).
Tractable problems
Tractable problems can be solved with programs that have a running time
that increases relatively slowly with increasing amounts of input data.
For example, searching through a list of items requires a computing time that
increases roughly proportionately (linearly) with the number of items searched.
We can write the running time of a program as a function of the number of items in the input (the input size), which is usually given as n.
For example:
Polynomial running time:
t = .0021 * n^2 + .003 * n + .00004
t = 4 * n^3 + 5 * n^2 -3
Programs whose running time is a polynomial function of the input size, n, are tractable
Programs whose running time is a polynomial function of log(n) are also tractable.
log(n) is the inverse function of exponentials. If 2^x = n, then log(n) = x.
Thus, the following running times would be considered tractable:
Intractable Problems
Intractable problems have running times that increase much faster than polynomial of n.
For example, exponential functions (2^n) and factorials (n!).
Tower of Hanoi program (see Homework 6) has a running time that is roughly proportional to 2^n. As you increase n by 1, the running time approximately doubles. An input size of 100 would take trillions of years to run!
The Traveling Salesman Problem (find the shortest route between a group of cities to visit them all once and return home) has a running time that is roughly proportional to the factorial of n. The running time for a program solving this problem is billions of years for an input size of 22.
Many important practical problems are intractable. Much Computer Science research is devoted to finding more efficient ways of solving these problems.