Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSC 380: Design and Analysis of Algorithms

Similar presentations


Presentation on theme: "CSC 380: Design and Analysis of Algorithms"— Presentation transcript:

1 CSC 380: Design and Analysis of Algorithms
Dr. Curry Guinn

2 Quick Info Dr. Curry Guinn CIS 2015 guinnc@uncw.edu
Office Hours: MWF: 10:00am-11:00m and by appointment

3 Outline of today Homework due Thursday Night P vs NP

4 Relations between Problems, Algorithms, and Programs
Algorithm Program Program Program Program

5 P vs NP P = Polynomial NP = Non-deterministic Polynomial
What is a non-deterministic algorithm?

6 Example NP-Complete Problems
Path-Finding (Traveling salesman) Map coloring Scheduling and Matching (bin packing) 2-D arrangement problems Planning problems Clique

7 Traveling Salesman

8 The Traveling Salesman problem
A traveling salesman needs to visit n cities, going to each city exactly once, and return to his starting city. Assume every city is connected to every other city, but the cost of traveling differs for each city pair. What is the sequence of cities that minimizes the overall cost? 8

9 Solving the TSP No algorithm is known that will guarantee finding the best solution except by examining all possible circuits (or equivalent approaches). For n = 25, (n – 1)! / 2 = 24! / 2 ≈ 3 × If we take one nanosecond to calculate the cost of each circuit, we still need 3 × 1014 seconds, or about 10 million years. The problem is provably NP-complete. 9

10 TSP Problems Planning routes Genome sequencing 10

11 Example tour on circuit board
3,038 points to visit 11

12 Class Scheduling Problem
With N teachers with certain hour restrictions M classes to be scheduled, Can we: Schedule all the classes Make sure that no two teachers teach the same class at the same time No teacher is scheduled to teach two classes at once

13 Graph Coloring Problem

14 NP-Complete Problems A decision problem D is NP-complete if it’s as hard as any problem in NP, i.e., D is in NP every problem in NP is polynomial-time reducible to D Cook’s theorem (1971): CNF-sat is NP-complete

15 NP-Complete Problems (cont.)
Other NP-complete problems obtained through polynomial- time reductions from a known NP-complete problem Examples: TSP, knapsack, partition, graph-coloring and hundreds of other problems of combinatorial nature

16 P = NP ? Dilemma Revisited
P = NP would imply that every problem in NP, including all NP-complete problems, could be solved in polynomial time If a polynomial-time algorithm for just one NP- complete problem is discovered, then every problem in NP can be solved in polynomial time, i.e., P = NP Most but not all researchers believe that P  NP , i.e. P is a proper subset of NP

17 Problems Solvable by Computers …
Problems that are ‘NP-hard’ are ‘hard’ in the sense that the answer cannot be found in polynomial time and are ‘NP’. It has been demonstrated that there are certain NP problems to which all other NP problems can be reduced. This means that if one of these problems can be solved in polynomial time, they all can. Such problems are called ‘NP-complete’.

18 NP-Complete Problems NP-complete problems have:
An exponential upper bound A polynomial lower bound We have only found exponential algorithms, so it appears to be intractable. But... we can’t prove that an exponential solution is needed, we can’t prove that a polynomial algorithm cannot be developed, so we can’t say the problem is intractable...

19 NP-Complete Problems The upper bound suggests the problem is intractable The lower bound suggests the problem is tractable They are all reducible to each other If we find a reasonable algorithm (or prove intractability) for one, then we can do it for all of them!

20 Classes P and NP Class P collects all problems that are solvable in polynomial time by a deterministic algorithm Class NP is the analogous class for non-deterministic algorithms Note that P  NP Is P = NP ? NP P

21 Traveling Salesman Problem
It is in NP Yes! Is it in P? We have no idea We are unable to exhibit a polynomial time algorithm on a TM We cannot prove that such algorithm does not exist NP P

22 Which Venn Diagram is Accurate?
P=NP PNP NP P (b) P=NP · TSP (a) · TSP NP P (c) · TSP

23 Become Famous! To get famous in a hurry, for any NP-Complete problem:
Raise the lower bound (via a stronger proof) Lower the upper bound (via a better algorithm) The Clay Mathematics Institute has offered a $1 million US prize for the first correct proof.

24 What Do Computer Scientists Think
2002 Survey 2012 Survey When will this question be resolved? : 11 : 33 : 28 : 9 : 6 Never: 5

25 What Do Computer Scientists Think
2002 Survey 2012 Survey Is P = NP? NO: 83% YES: 12% Obfuscatory or no answer: 5%

26 The Satisfiability Problem
Given a set of propositional logic clauses, find an assignment of truth values to each symbol so that all of the clauses are true. (P -> Q & S) & (~P & ~Q) & (S | ~Q)

27 3SAT is a special case All clauses contain the disjunction of 3 terms
Disjunction means OR Each term is of the form P or ~P. (P | Q | ~S) & (~P | ~Q | ~S) & (P | ~Q | S) It turns out that any SAT case, can be transformed into 3SAT

28 3SAT is an NP-complete problem
Which means that it is map-able to other NP-complete problems such as Traveling salesman Clique Map coloring Knapsack, Etc. What do I mean by “map-able”?

29 Suppose we want to actually write code to solve this problem
How do we do it? Analysis Design Implement Test

30 Analysis Can we write down the problem?

31 Write down the problem Find a set of truth assignments for the propositional symbols such that are of the clauses are true. Each clause consist of a disjunction (OR) of three terms. Each term is either a proposition symbol or its negation (i.e., P or ~P). More generally, for a particular problem, we will have n different propositional symbols and m different clauses. Do you want to add anything?

32 Find the nouns. Why?

33 For Next Class, Friday Chapter 11: P vs. Np Homework due Tonight


Download ppt "CSC 380: Design and Analysis of Algorithms"

Similar presentations


Ads by Google