Top Banner
Complexity ©D.Moshkovitz 1 Introduction
38

Complexity ©D.Moshkovitz 1 Introduction. Complexity ©D.Moshkovitz 2 Introduction Objectives: –To introduce some of the basic concepts of complexity theory.

Dec 19, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Complexity ©D.Moshkovitz 1 Introduction. Complexity ©D.Moshkovitz 2 Introduction Objectives: –To introduce some of the basic concepts of complexity theory.

Complexity©D.Moshkovitz

1

Introduction

Page 2: Complexity ©D.Moshkovitz 1 Introduction. Complexity ©D.Moshkovitz 2 Introduction Objectives: –To introduce some of the basic concepts of complexity theory.

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…

Page 3: Complexity ©D.Moshkovitz 1 Introduction. Complexity ©D.Moshkovitz 2 Introduction Objectives: –To introduce some of the basic concepts of complexity theory.

Complexity©D.Moshkovitz

3

The Crazy Tea PartyProblem To seat all guests at a round table, so

people who sit in adjacent seats like each other.

John Mary Bob Jane Alice

John

Mary

Bob

Jane

Alice

Page 4: Complexity ©D.Moshkovitz 1 Introduction. Complexity ©D.Moshkovitz 2 Introduction Objectives: –To introduce some of the basic concepts of complexity theory.

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

Page 5: Complexity ©D.Moshkovitz 1 Introduction. Complexity ©D.Moshkovitz 2 Introduction Objectives: –To introduce some of the basic concepts of complexity theory.

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.

Page 6: Complexity ©D.Moshkovitz 1 Introduction. Complexity ©D.Moshkovitz 2 Introduction Objectives: –To introduce some of the basic concepts of complexity theory.

Complexity©D.Moshkovitz

6

How Much Time Should This Take? (worse case)guests steps

n (n-1)!

5 24

15 87178291200

100 9·10155

say our computer is capable of 1010

instructions per second, this will still take 3·10138 years!

Page 7: Complexity ©D.Moshkovitz 1 Introduction. Complexity ©D.Moshkovitz 2 Introduction Objectives: –To introduce some of the basic concepts of complexity theory.

Complexity©D.Moshkovitz

7

ToursProblem Plan a trip that visits every site exactly

once.

Page 8: Complexity ©D.Moshkovitz 1 Introduction. Complexity ©D.Moshkovitz 2 Introduction Objectives: –To introduce some of the basic concepts of complexity theory.

Complexity©D.Moshkovitz

8

Solution for the ExampleProblem Plan a trip that visits every site exactly

once.

Page 9: Complexity ©D.Moshkovitz 1 Introduction. Complexity ©D.Moshkovitz 2 Introduction Objectives: –To introduce some of the basic concepts of complexity theory.

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

Page 10: Complexity ©D.Moshkovitz 1 Introduction. Complexity ©D.Moshkovitz 2 Introduction Objectives: –To introduce some of the basic concepts of complexity theory.

Complexity©D.Moshkovitz

10

How Much Time Should This Take?

sites steps

n n!

5 120

15 1307674368000

100 9·10157

If our computer can carry out 10,000 instructions per

second, than it will take us 4 years!

Page 11: Complexity ©D.Moshkovitz 1 Introduction. Complexity ©D.Moshkovitz 2 Introduction Objectives: –To introduce some of the basic concepts of complexity theory.

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?

Page 12: Complexity ©D.Moshkovitz 1 Introduction. Complexity ©D.Moshkovitz 2 Introduction Objectives: –To introduce some of the basic concepts of complexity theory.

Complexity©D.Moshkovitz

12

Food for Thought…

• Can you design an efficient algorithm for the tour problem if the sites’ map contains no cycles?

Page 13: Complexity ©D.Moshkovitz 1 Introduction. Complexity ©D.Moshkovitz 2 Introduction Objectives: –To introduce some of the basic concepts of complexity theory.

Complexity©D.Moshkovitz

13

Growth Rate: Sketch

10n

n2

2n

n! =2O(n lg

n)

input length

time

Page 14: Complexity ©D.Moshkovitz 1 Introduction. Complexity ©D.Moshkovitz 2 Introduction Objectives: –To introduce some of the basic concepts of complexity theory.

Complexity©D.Moshkovitz

14

The World According to Complexity

reasonable unreasonable

polynomial nO(1)

exponential 2nO(1)

Page 15: Complexity ©D.Moshkovitz 1 Introduction. Complexity ©D.Moshkovitz 2 Introduction Objectives: –To introduce some of the basic concepts of complexity theory.

Complexity©D.Moshkovitz

15

Could One be Fundamentally Harder

than the Other?

Tour

Seating

?

Page 16: Complexity ©D.Moshkovitz 1 Introduction. Complexity ©D.Moshkovitz 2 Introduction Objectives: –To introduce some of the basic concepts of complexity theory.

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

Page 17: Complexity ©D.Moshkovitz 1 Introduction. Complexity ©D.Moshkovitz 2 Introduction Objectives: –To introduce some of the basic concepts of complexity theory.

Complexity©D.Moshkovitz

17

Reductions

B p A

B cannot be radically harder than A

In other words: A is at least as hard as B

Page 18: Complexity ©D.Moshkovitz 1 Introduction. Complexity ©D.Moshkovitz 2 Introduction Objectives: –To introduce some of the basic concepts of complexity theory.

Complexity©D.Moshkovitz

18

Which One is Harder?

Tour

Seating

?

Page 19: Complexity ©D.Moshkovitz 1 Introduction. Complexity ©D.Moshkovitz 2 Introduction Objectives: –To introduce some of the basic concepts of complexity theory.

Complexity©D.Moshkovitz

19

Reduce Tour to SeatingFirst Observation: The problems aren’t so

different

site guest

“directly reachable from…”

“liked by…”

Page 20: Complexity ©D.Moshkovitz 1 Introduction. Complexity ©D.Moshkovitz 2 Introduction Objectives: –To introduce some of the basic concepts of complexity theory.

Complexity©D.Moshkovitz

20

Reduce Tour to SeatingSecond Observation: Completing the circle

• Let’s invite to our party a very popular guest,• i.e one who can sit next to everyone else.

Page 21: Complexity ©D.Moshkovitz 1 Introduction. Complexity ©D.Moshkovitz 2 Introduction Objectives: –To introduce some of the basic concepts of complexity theory.

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

Page 22: Complexity ©D.Moshkovitz 1 Introduction. Complexity ©D.Moshkovitz 2 Introduction Objectives: –To introduce some of the basic concepts of complexity theory.

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

. . .

Page 23: Complexity ©D.Moshkovitz 1 Introduction. Complexity ©D.Moshkovitz 2 Introduction Objectives: –To introduce some of the basic concepts of complexity theory.

Complexity©D.Moshkovitz

23

Bottom Line

The seating problem is at least as hard as the tour problem

Page 24: Complexity ©D.Moshkovitz 1 Introduction. Complexity ©D.Moshkovitz 2 Introduction Objectives: –To introduce some of the basic concepts of complexity theory.

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

Page 25: Complexity ©D.Moshkovitz 1 Introduction. Complexity ©D.Moshkovitz 2 Introduction Objectives: –To introduce some of the basic concepts of complexity theory.

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.

Page 26: Complexity ©D.Moshkovitz 1 Introduction. Complexity ©D.Moshkovitz 2 Introduction Objectives: –To introduce some of the basic concepts of complexity theory.

Complexity©D.Moshkovitz

26

Food for Thought…

• Can you reduce the seating problem to the tour problem?

Page 27: Complexity ©D.Moshkovitz 1 Introduction. Complexity ©D.Moshkovitz 2 Introduction Objectives: –To introduce some of the basic concepts of complexity theory.

Complexity©D.Moshkovitz

27

NPC

NPC

Contains thousands of distinct problem

exponential algorithms

efficient algorithms

?

each reducible to all others

Page 28: Complexity ©D.Moshkovitz 1 Introduction. Complexity ©D.Moshkovitz 2 Introduction Objectives: –To introduce some of the basic concepts of complexity theory.

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…www.claymath.org/prizeproblems/pvsnp.htm

• Philosophical: if P=NP – Human ingenuity unnecessary– No need for mathematicians!!

• Is nature nondeterministic?

Page 29: Complexity ©D.Moshkovitz 1 Introduction. Complexity ©D.Moshkovitz 2 Introduction Objectives: –To introduce some of the basic concepts of complexity theory.

Complexity©D.Moshkovitz

29

What More?

• Let’s review some more questions to be discussed in this course.

Page 30: Complexity ©D.Moshkovitz 1 Introduction. Complexity ©D.Moshkovitz 2 Introduction Objectives: –To introduce some of the basic concepts of complexity theory.

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

Page 31: Complexity ©D.Moshkovitz 1 Introduction. Complexity ©D.Moshkovitz 2 Introduction Objectives: –To introduce some of the basic concepts of complexity theory.

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

Page 32: Complexity ©D.Moshkovitz 1 Introduction. Complexity ©D.Moshkovitz 2 Introduction Objectives: –To introduce some of the basic concepts of complexity theory.

Complexity©D.Moshkovitz

32

Is Running Time the Only Precious Resource?

• How about memory (space)?• Are there other resources?

Page 33: Complexity ©D.Moshkovitz 1 Introduction. Complexity ©D.Moshkovitz 2 Introduction Objectives: –To introduce some of the basic concepts of complexity theory.

Complexity©D.Moshkovitz

33

Games

• Each player picks a word, which begins with the letter that ended the previous word.

Apple EggGirl LordDog GuyYard Deer

Page 34: Complexity ©D.Moshkovitz 1 Introduction. Complexity ©D.Moshkovitz 2 Introduction Objectives: –To introduce some of the basic concepts of complexity theory.

Complexity©D.Moshkovitz

34

Dictionary

Apple

Egg Girl

Ear

LordLordDog

Red

Page 35: Complexity ©D.Moshkovitz 1 Introduction. Complexity ©D.Moshkovitz 2 Introduction Objectives: –To introduce some of the basic concepts of complexity theory.

Complexity©D.Moshkovitz

35

Game Tree

Egg Girl DogApple Ear LordRed

GirlEgg EarDog DogLord Girl Red

Lord Lord

Dog

Dog

Girl

Lord

Dog Girl

Lord

Girl Girl Red Lord Dog Lord Dog Girl

Apple

Egg Girl

Ear

LordLordDog

Red

Page 36: Complexity ©D.Moshkovitz 1 Introduction. Complexity ©D.Moshkovitz 2 Introduction Objectives: –To introduce some of the basic concepts of complexity theory.

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?

Page 37: Complexity ©D.Moshkovitz 1 Introduction. Complexity ©D.Moshkovitz 2 Introduction Objectives: –To introduce some of the basic concepts of complexity theory.

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.

Page 38: Complexity ©D.Moshkovitz 1 Introduction. Complexity ©D.Moshkovitz 2 Introduction Objectives: –To introduce some of the basic concepts of complexity theory.

Complexity©D.Moshkovitz

38

Summary

• We also mentioned some of the topics we will discuss later in the course:– Approximation– Space-bounded computations