Presentation is loading. Please wait.

Presentation is loading. Please wait.

Applied Computer Science II Chapter 7: Time Complexity Prof. Dr. Luc De Raedt Institut für Informatik Albert-Ludwigs Universität Freiburg Germany.

Similar presentations


Presentation on theme: "Applied Computer Science II Chapter 7: Time Complexity Prof. Dr. Luc De Raedt Institut für Informatik Albert-Ludwigs Universität Freiburg Germany."— Presentation transcript:

1 Applied Computer Science II Chapter 7: Time Complexity Prof. Dr. Luc De Raedt Institut für Informatik Albert-Ludwigs Universität Freiburg Germany

2 Overview Measuring complexity The class P The class NP NP-completeness Additional NP-complete problems

3 Measuring complexity How much time needed to decide a language Use Machine M1

4 Measuring complexity Worst-case versus average-case We typically use big-O and small-o notation (cf. ACS I); asymptotic analysis

5 Big-O

6

7 Small-o

8 Time Complexity

9 Analyzing algorithms

10 2-tape machine

11 Complexity relationship among models

12

13 Definition 7.9 including figure 7.1

14

15

16 Differences in models Polynomial difference between single- and multiple tape deterministic TM Exponential difference between deterministic and non-deterministic TM Compare exponential versus polynomial behaviour !

17 Towards the class P Distinction between : Exponential algorithms –Brute force search –Impractical Polynomial –Practical –Robust for reasonable models of computation (I.e. polynomially equivalent) Here, we ignore differences between, e.g., level of abstraction

18 P is invariant for all models of computation that are polynomially equivalent to a single tape deterministic TM P roughly corresponds to the class of problems that are realistically solvable on a computer

19 Conventions High-level descriptions of algorithms Abstraction of specific model used (as long as polynomially equivalent) Algorithms proceed in numbered stages Analysis in two steps : –A polynomial bound on the number of stages –Each stage can be implemented in polynomial time on deterministic single tape TM (or poly. Equivalent model)

20 Conventions Encoding method for problems We use notation as before Reasonable methods require encoding and decoding of objects into other (internal ?) representation to require polynomial time. E.g. 111111111 (unreasonable) instead of 9 (or other base k-notation)

21 Encoding Graphs Option 1 : –List of nodes –List of edges Option 2 : –Adjacency matrix

22 Figure 7.2

23 Insert algorithm

24

25

26

27 Towards the class NP

28 HAMPATH Easy to obtain exponential time algorithm : –Generate all paths of length m (no. of nodes) and check whether they are hamiltonian Polynomial verifiability : –Checking whether a given path is hamiltonian can be done in polynomial time Verifying existence of hamiltonian path is easier than determining the existence Consider also Similar for COMPOSITES

29 The class NP

30 NTM for HAMPATH Algorithm

31 Proof

32

33

34

35 P versus NP

36 P= the class of languages where membership can be decided quickly NP=the class of languages where membership can be verified quickly NP-complete problems : if a polynomial time (determ.) algorithm exists for one NP-complete problem, then P=NP

37

38 Polynomial time reducibility Fig 7.6

39 Proof: N works in polynomial time

40

41 Fig 7.7

42 NP-completeness

43

44

45

46

47

48

49

50

51

52

53

54 Set Covering

55 BinPacking

56 Traveling Salesman Problem

57 Coloring

58 Key Reductions SAT 3SAT SetCoverClique VertexCover SubsetSum Partition BinPacking Hampath UHampath TSP Coloring

59 Conclusions The class P The class NP NP-completeness(e.g. 3SAT) Polynomial time reductions Two further classes : –coNP : –NP-hard:

60 Standard Reference Garey and Johson, Computers and Intractability – A guide to the theory of NP- completeness, W.H.Freeman, 1979.


Download ppt "Applied Computer Science II Chapter 7: Time Complexity Prof. Dr. Luc De Raedt Institut für Informatik Albert-Ludwigs Universität Freiburg Germany."

Similar presentations


Ads by Google