Complexity ©D.Moshkovitz 1 Introduction
Complexity ©D.Moshkovitz 2 Introduction Objectives: –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. JohnMaryBobJaneAlice John Mary Bob Jane Alice
Complexity ©D.Moshkovitz 4 Solution for the Example Alice Bob Jane John Problem To seat all guests at a round table, so people who sit an adjacent seats like each other. Mary
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)! 9 · say our computer is capable of instructions per second, this will still take 3 · years!
Complexity ©D.Moshkovitz 7 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? sites steps n n! 9 · If our computer can carry out 10,000 instructions per second, than it will take us 4 years!
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 10n n2n2 2n2n n! =2 O(n lg n) input length time
Complexity ©D.Moshkovitz 14 The World According to Complexity reasonableunreasonable polynomial n O(1) exponential 2 n O(1)
Complexity ©D.Moshkovitz 15 Could One be Fundamentally Harder than the Other? Tour Seating ?
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 pp A 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? Tour Seating ?
Complexity ©D.Moshkovitz 19 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 Contains thousands of distinct problem exponential algorithms efficient algorithms ? each reducible to all others
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 $8 $10 $13 $12 $19 $3 $17 $13
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. $8 $10 $13 $12 $19 $3 $17 $13
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. Apple Egg Girl Lord DogGuy YardDeer
Complexity ©D.Moshkovitz 34 Dictionary Apple EggGirl Ear Lord Dog Red
Complexity ©D.Moshkovitz 35 Game Tree EggGirlDogAppleEarLordRed GirlEggEarDog LordGirlRed Lord Dog Girl Lord DogGirl Lord Girl RedLordDogLordDogGirl Apple Egg Girl Ear Lord Dog Red
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