Presentation is loading. Please wait.

Presentation is loading. Please wait.

Complexity Introduction Complexity ©D.Moshkovitz.

Similar presentations


Presentation on theme: "Complexity Introduction Complexity ©D.Moshkovitz."— Presentation transcript:

1 Complexity Introduction Complexity ©D.Moshkovitz

2 Introduction Objectives: Overview: Tea parties and computations
To introduce some of the basic concepts of complexity theory. Overview: Tea parties and computations Growth rate and reasonability Reducibility … And more… Complexity ©D.Moshkovitz

3 The Crazy Tea Party Problem To seat all guests at a round table, so people who sit in adjacent seats like each other. John Mary Bob Jane Alice Complexity ©D.Moshkovitz

4 Solution for the Example
Problem To seat all guests at a round table, so people who sit an adjacent seats like each other. John Jane Mary Alice Bob Complexity ©D.Moshkovitz

5 Naive Algorithm For each ordering of the guests around the table
Verify each guest likes the guest sitting in the next seat. Complexity ©D.Moshkovitz

6 How Much Time Should This Take? (worse case)
guests steps n (n-1)! 5 24 say our computer is capable of 1010 instructions per second, this will still take  3·10138 years! 15 100 9·10155 Complexity ©D.Moshkovitz

7 Problem Plan a trip that visits every site exactly once.
Tours Problem Plan a trip that visits every site exactly once. Complexity ©D.Moshkovitz

8 Solution for the Example
Problem Plan a trip that visits every site exactly once. Complexity ©D.Moshkovitz

9 Naive Algorithm (Backtracking)
For each site Try out all reachable sites, which have not been visited yet Backtrack and retry Repeat the process until stuck Complexity ©D.Moshkovitz

10 How Much Time Should This Take?
If our computer can carry out 10,000 instructions per second, than it will take us 4 years! sites steps n n! 5 120 15 100 9·10157 Complexity ©D.Moshkovitz

11 Is a Problem Tractable? YES! And here’s the efficient algorithm for it
NO! and I can prove it and what if neither is the case? Complexity ©D.Moshkovitz

12 Food for Thought… Can you design an efficient algorithm for the tour problem if the sites’ map contains no cycles? Complexity ©D.Moshkovitz

13 Growth Rate: Sketch n! =2O(n lg n) 2n n2 10n time input length
Complexity ©D.Moshkovitz

14 The World According to Complexity
reasonable unreasonable polynomial  nO(1) exponential  2nO(1) Complexity ©D.Moshkovitz

15 Could One be Fundamentally Harder than the Other?
Seating Tour Complexity ©D.Moshkovitz

16 Relations Between Problems
Assuming an efficient procedure for problem A, there is an efficient procedure for problem B B cannot be radically harder than A Complexity ©D.Moshkovitz

17 Reductions B A p B cannot be radically harder than A In other words: A is at least as hard as B Complexity ©D.Moshkovitz

18 Which One is Harder? ? Seating Tour Complexity ©D.Moshkovitz

19 “directly reachable from…”
Reduce Tour to Seating First Observation: The problems aren’t so different site guest “directly reachable from…” “liked by…” Complexity ©D.Moshkovitz

20 Reduce Tour to Seating Second Observation: Completing the circle
Let’s invite to our party a very popular guest, i.e one who can sit next to everyone else. Complexity ©D.Moshkovitz

21 Reduce Tour to Seating If there is a tour, there is also a way to seat all the imagined guests around the table. popular guest . . . . . . Complexity ©D.Moshkovitz

22 Reduce Tour to Seating If there is a seating, we can easily find a tour path (no tour, no seating). popular guest . . . . . . Complexity ©D.Moshkovitz

23 Bottom Line The seating problem is at least as hard as the tour problem Complexity ©D.Moshkovitz

24 Discussion Although we couldn’t come up with an efficient algorithm for the problems Nor to prove they don’t have one, We managed to show a very powerful claim regarding the relation between their hardness Complexity ©D.Moshkovitz

25 Discussion Interestingly, we can also reduce the seating problem to the tour problem. Moreover, there is a whole class of problems, which can be pairwise efficiently reduced to each other. Complexity ©D.Moshkovitz

26 Food for Thought… Can you reduce the seating problem to the tour problem? Complexity ©D.Moshkovitz

27 NPC NPC  ? exponential algorithms efficient algorithms
Contains thousands of distinct problem NPC each reducible to all others exponential algorithms efficient algorithms ? Complexity ©D.Moshkovitz

28 How Can Studying Complexity Make You a Millionaire?
P vs NP is the most fundamental open question of computer science. Resolving it would get you great honor … as well as substantial fortune… Philosophical: if P=NP Human ingenuity unnecessary No need for mathematicians!! Is nature nondeterministic? Complexity ©D.Moshkovitz

29 What More? Let’s review some more questions to be discussed in this course. Complexity ©D.Moshkovitz

30 Generalized Tour Problem
Add prices to the roads of the tour problem Ask for the least costly tour $3 $17 $13 $8 $19 $10 $13 $12 Complexity ©D.Moshkovitz

31 Approximation How about approximating the optimal tour?
I.e – finding a tour which costs, say, no more than twice as much as the least costly. $3 $17 $13 $8 $19 $10 $13 $12 Complexity ©D.Moshkovitz

32 Is Running Time the Only Precious Resource?
How about memory (space)? Are there other resources? Complexity ©D.Moshkovitz

33 Games Each player picks a word, which begins with the letter that ended the previous word. Girl Apple Lord Yard Deer Egg Dog Guy Complexity ©D.Moshkovitz

34 Dictionary Apple Egg Girl Ear Lord Dog Red Complexity ©D.Moshkovitz

35 Game Tree Apple Egg Girl Ear Lord Dog Red Egg Girl Dog Apple Ear Lord
Complexity ©D.Moshkovitz

36 Winning Games How can we find a winning strategy for this game?
How much space would it take to compute it using game trees? Complexity ©D.Moshkovitz

37  Summary We got to know two problems:
The seating problem (HAMILTONIAN-CYCLE) The tour problem (HAMILTONIAN-PATH) Although we could say very little about them, we managed to show their computational hardness are related. Moreover, we claimed they are part of a large class of problems, called NPC. Complexity ©D.Moshkovitz

38 Summary We also mentioned some of the topics we will discuss later in the course: Approximation Space-bounded computations Complexity ©D.Moshkovitz


Download ppt "Complexity Introduction Complexity ©D.Moshkovitz."

Similar presentations


Ads by Google