Download Feasibility and Infeasibility

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Big O notation wikipedia , lookup

Factorization of polynomials over finite fields wikipedia , lookup

Halting problem wikipedia , lookup

Transcript
Feasibility and Infeasibility
Are all problems easy to solve?
Not Computable vs. Not
Feasible
Last week we spoke about problems that are
not computable such as the halting problem.
This week we speak about problems that
can be computed but they are difficult to
solve. These problems are called Infeasible.
A growing penny vs. $1M
• If I were to offer you one penny today, 2
cents tomorrow, 4 cents the next day, and so
on, each day doubling it for 30 days - or I
would offer to you 1 million dollars which
would you take?
Growth of pennies in 30 days
0.01
0.32
$ 10.24
$ 327.68
$ 10,485.76
$ 335,544.32
0.02
0.64
$ 20.48
$ 655.36
$ 20,971.52
$ 671,088.64
0.04
$
1.28
$
40.96
$ 1,310.72
$ 41,943.04
$ 1,342,177.28
0.08
$
2.56
$
81.92
$ 2,621.44
$ 83,886.08
$ 2,684,354.56
0.16
$
5.12
$
163.84
$ 5,242.88
$ 167,772.16
$ 5,368,709.12
Note the exponential rate of growth: 2days
Rate of Growth
• The idea is to look at the rate of growth
of time or steps to solve the problem in
relation to the input. In other words how
quickly does the workload increase for a
one unit increase of the input?
• Exponential and factorial growths are
infeasible.
Example: Sorting
Problem: Sort a set of n numbers.
Example sort: 5, 8, 2, 16, 7
How would you solve that?
Algorithm 1 - Exhaustive listing
1. List all permutations (orderings) of the data
2. Pick the one that is sorted.
5, 8, 2, 16, 7
not sorted try again…
8, 5, 2, 16, 7
not sorted try again…
…
n n!
How much work does it take?
The number of permutations is
n*(n-1)*(n-2)*...*3*2*1 = n!
3
6
4
24
5
120
6
720
7
5,040
8
40,320
Algorithm 2 - Selection sort
1. Find the largest of the n data points
2. Find the largest of the remaining n-1 data
points (loop)
3. Find the largest of the remaining n-2 data
points (loop)
n n*(n+1)/2
… until only the smallest data
3 6
point is remaining
4 10
How much work does this take?
n + (n-1) + (n-2) + ... + 3 + 2
+ 1 = n*(n+1)/2
5
15
6
21
7
28
8
36
Compare algorithm 1 and algorithm 2
Note that if n = 5
• The exhaustive listing and search takes 5! =
120 units of work
• The selection sort takes 15 units of work
Algorithm 1 is infeasible whereas algorithm 2 is
feasible.
Infeasible Problem vs. Infeasible
Algorithm
• Sorting is a feasible problem because there
exists a feasible algorithm (algorithm 2
selection sort and others).
• Just make sure not to use Algorithm 1 - an
infeasible algorithm.
• Sometimes there are infeasible problemspeople have not found a feasible algorithm for
it.
Two examples of infeasible
problems
1. Traveling salesman problem
2. Chess
Questions
• What does infeasible mean?
• What is the difference between an
unsolvable problem and an infeasible
problem?
• If I have 1 million numbers to sort – won’t
that take a long time? Is that infeasible?
Explain.