Presentation is loading. Please wait.

Presentation is loading. Please wait.

Feasibility and Infeasibility Are all problems easy to solve?

Similar presentations


Presentation on theme: "Feasibility and Infeasibility Are all problems easy to solve?"— Presentation transcript:

1 Feasibility and Infeasibility Are all problems easy to solve?

2 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.

3 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?

4 Growth of pennies in 30 days Note the exponential rate of growth: 2 days

5 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.

6 Example: Sorting Problem: Sort a set of n numbers. Example sort: 5, 8, 2, 16, 7 How would you solve that?

7 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, 7not sorted try again… … How much work does it take? The number of permutations is n*(n-1)*(n-2)*...*3*2*1 = n! nn! 36 424 5120 6720 75,040 840,320

8 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) … until only the smallest data point is remaining How much work does this take? n + (n-1) + (n-2) +... + 3 + 2 + 1 = n*(n+1)/2 nn*(n+1)/2 36 410 515 621 728 836

9 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.

10 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 problems- people have not found a feasible algorithm for it.

11 Two examples of infeasible problems 1.Traveling salesman problem 2.Chess

12 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.


Download ppt "Feasibility and Infeasibility Are all problems easy to solve?"

Similar presentations


Ads by Google