+ All Categories
Home > Documents > The CS 5 Timesjulie/cs5/f18/Lecture07Black.pdf · Cartoon courtesy of “Computers and...

The CS 5 Timesjulie/cs5/f18/Lecture07Black.pdf · Cartoon courtesy of “Computers and...

Date post: 03-Oct-2020
Category:
Upload: others
View: 0 times
Download: 0 times
Share this document with a friend
37
The CS 5 Times Penguin Rescue! Dunedin, New Zealand (Penguin Press): A daring mission has been mounted to rescue two adorable penguins who had been given up as lost after a spaceship crash. Risking her life with an untested experimental jet pack, a brave Chemistry penguin mixed a witches’ brew of propellant, fueled the pack, and set off across the sky in search of her missing colleagues, who were running out of fish when last heard from. “We are, like, so grateful for this, like, attempt, and, like, we, like, hope for her, like, success,” stated a jittery CS 5 student. “We like, love our, like, penguins and are, like, so helpless with our, like, homework assignments without, like, their, like, help.” Further quotes were unavailable due to an unexpected attack from a WRIT 1 instructor.
Transcript
Page 1: The CS 5 Timesjulie/cs5/f18/Lecture07Black.pdf · Cartoon courtesy of “Computers and Intractability: A Guide to the Theory of NP-Completeness” by M. Garey and D. Johnson “I

The CS 5 TimesPenguin Rescue!Dunedin, New Zealand (Penguin Press):

A daring mission has beenmounted to rescue two adorable penguinswho had been given up as lost after aspaceship crash. Risking her life with anuntested experimental jet pack, a brave Chemistry penguin mixed a witches’ brew of propellant, fueled the pack, and set off across the sky in search of her missing colleagues, who were running out of fish when last heard from.

“We are, like, so grateful for this, like, attempt, and, like, we, like, hope for her, like, success,” stated a jittery CS 5 student. “We like, love our, like, penguins and are, like, so helpless with our, like, homework assignments without, like, their, like, help.”

Further quotes were unavailable due to an unexpected attack from a WRIT 1 instructor.

Page 2: The CS 5 Timesjulie/cs5/f18/Lecture07Black.pdf · Cartoon courtesy of “Computers and Intractability: A Guide to the Theory of NP-Completeness” by M. Garey and D. Johnson “I

Mergesort

msort([42, 3, 1, 5, 27, 8, 2, 7])

msort([42, 3, 1, 5]) msort([27, 8, 2, 7])

merge([1, 3, 5, 42], [2, 7, 8, 27])

[

Page 3: The CS 5 Timesjulie/cs5/f18/Lecture07Black.pdf · Cartoon courtesy of “Computers and Intractability: A Guide to the Theory of NP-Completeness” by M. Garey and D. Johnson “I

Mergesort

msort([42, 3, 1, 5, 27, 8, 2, 7])

msort([42, 3, 1, 5]) msort([27, 8, 2, 7])

merge([1, 3, 5, 42], [2, 7, 8, 27])

[1,

Page 4: The CS 5 Timesjulie/cs5/f18/Lecture07Black.pdf · Cartoon courtesy of “Computers and Intractability: A Guide to the Theory of NP-Completeness” by M. Garey and D. Johnson “I

Mergesort

msort([42, 3, 1, 5, 27, 8, 2, 7])

msort([42, 3, 1, 5]) msort([27, 8, 2, 7])

merge([1, 3, 5, 42], [2, 7, 8, 27])

[1,2

✓ ✓

Page 5: The CS 5 Timesjulie/cs5/f18/Lecture07Black.pdf · Cartoon courtesy of “Computers and Intractability: A Guide to the Theory of NP-Completeness” by M. Garey and D. Johnson “I

Mergesort

msort([42, 3, 1, 5, 27, 8, 2, 7])

msort([42, 3, 1, 5]) msort([27, 8, 2, 7])

merge([1, 3, 5, 42], [2, 7, 8, 27])

[1,2,3

✓ ✓✓

Page 6: The CS 5 Timesjulie/cs5/f18/Lecture07Black.pdf · Cartoon courtesy of “Computers and Intractability: A Guide to the Theory of NP-Completeness” by M. Garey and D. Johnson “I

Mergesort

msort([42, 3, 1, 5, 27, 8, 2, 7])

msort([42, 3, 1, 5]) msort([27, 8, 2, 7])

merge([1, 3, 5, 42], [2, 7, 8, 27])

[1,2,3,5

✓ ✓✓ ✓

Page 7: The CS 5 Timesjulie/cs5/f18/Lecture07Black.pdf · Cartoon courtesy of “Computers and Intractability: A Guide to the Theory of NP-Completeness” by M. Garey and D. Johnson “I

Mergesort

msort([42, 3, 1, 5, 27, 8, 2, 7])

msort([42, 3, 1, 5]) msort([27, 8, 2, 7])

merge([1, 3, 5, 42], [2, 7, 8, 27])

[1,2,3,5,7

✓ ✓✓ ✓ ✓

Page 8: The CS 5 Timesjulie/cs5/f18/Lecture07Black.pdf · Cartoon courtesy of “Computers and Intractability: A Guide to the Theory of NP-Completeness” by M. Garey and D. Johnson “I

Mergesort

msort([42, 3, 1, 5, 27, 8, 2, 7])

msort([42, 3, 1, 5]) msort([27, 8, 2, 7])

merge([1, 3, 5, 42], [2, 7, 8, 27])

[1,2,3,5,7,8

✓ ✓✓ ✓ ✓ ✓

Page 9: The CS 5 Timesjulie/cs5/f18/Lecture07Black.pdf · Cartoon courtesy of “Computers and Intractability: A Guide to the Theory of NP-Completeness” by M. Garey and D. Johnson “I

Mergesort

msort([42, 3, 1, 5, 27, 8, 2, 7])

msort([42, 3, 1, 5]) msort([27, 8, 2, 7])

merge([1, 3, 5, 42], [2, 7, 8, 27])

[1,2,3,5,7,8,27

✓ ✓✓ ✓ ✓ ✓ ✓

Page 10: The CS 5 Timesjulie/cs5/f18/Lecture07Black.pdf · Cartoon courtesy of “Computers and Intractability: A Guide to the Theory of NP-Completeness” by M. Garey and D. Johnson “I

Mergesort

msort([42, 3, 1, 5, 27, 8, 2, 7])

msort([42, 3, 1, 5]) msort([27, 8, 2, 7])

merge([1, 3, 5, 42], [2, 7, 8, 27])

[1,2,3,5,7,8,27,42]

✓ ✓✓ ✓ ✓ ✓ ✓✓

Done!

Page 11: The CS 5 Timesjulie/cs5/f18/Lecture07Black.pdf · Cartoon courtesy of “Computers and Intractability: A Guide to the Theory of NP-Completeness” by M. Garey and D. Johnson “I

Let’s try it out - and let’s not even make n a power of 2!

msort([42, 3, 1, 6, 5, 2, 7])

msort([42, 3, 1]) msort([6, 5, 2, 7])

Page 12: The CS 5 Timesjulie/cs5/f18/Lecture07Black.pdf · Cartoon courtesy of “Computers and Intractability: A Guide to the Theory of NP-Completeness” by M. Garey and D. Johnson “I

msort([42, 3, 1, 6, 5, 2, 7])

msort([42, 3, 1]) msort([6, 5, 2, 7])

msort([42]) msort([3, 1]) msort([6, 5]) msort([2, 7])

Page 13: The CS 5 Timesjulie/cs5/f18/Lecture07Black.pdf · Cartoon courtesy of “Computers and Intractability: A Guide to the Theory of NP-Completeness” by M. Garey and D. Johnson “I

msort([42, 3, 1, 6, 5, 2, 7])

msort([42, 3, 1]) msort([6, 5, 2, 7])

msort([42]) msort([3, 1]) msort([6, 5]) msort([2, 7])

[42]

msort([3])msort([1])

Page 14: The CS 5 Timesjulie/cs5/f18/Lecture07Black.pdf · Cartoon courtesy of “Computers and Intractability: A Guide to the Theory of NP-Completeness” by M. Garey and D. Johnson “I

msort([42, 3, 1, 6, 5, 2, 7])

msort([42, 3, 1]) msort([6, 5, 2, 7])

msort([42]) msort([3, 1]) msort([6, 5]) msort([2, 7])

[42]

msort([3])msort([1])

[3] [1]

Page 15: The CS 5 Timesjulie/cs5/f18/Lecture07Black.pdf · Cartoon courtesy of “Computers and Intractability: A Guide to the Theory of NP-Completeness” by M. Garey and D. Johnson “I

msort([42, 3, 1, 6, 5, 2, 7])

msort([42, 3, 1]) msort([6, 5, 2, 7])

msort([42]) msort([3, 1]) msort([6, 5]) msort([2, 7])

[42]

msort([3])msort([1])

[3] [1]

[1,3]

Page 16: The CS 5 Timesjulie/cs5/f18/Lecture07Black.pdf · Cartoon courtesy of “Computers and Intractability: A Guide to the Theory of NP-Completeness” by M. Garey and D. Johnson “I

msort([42, 3, 1, 6, 5, 2, 7])

msort([42, 3, 1]) msort([6, 5, 2, 7])

msort([42]) msort([3, 1]) msort([6, 5]) msort([2, 7])

[42]

msort([3])msort([1])

[3] [1]

[1,3]

[1,3,42]

Page 17: The CS 5 Timesjulie/cs5/f18/Lecture07Black.pdf · Cartoon courtesy of “Computers and Intractability: A Guide to the Theory of NP-Completeness” by M. Garey and D. Johnson “I

msort([42, 3, 1, 6, 5, 2, 7])

msort([42, 3, 1]) msort([6, 5, 2, 7])

msort([42]) msort([3, 1]) msort([6, 5]) msort([2, 7])

[42]

msort([3])msort([1])

[3] [1]

[1,3]

[1,3,42] [2, 5, 6, 7]

Page 18: The CS 5 Timesjulie/cs5/f18/Lecture07Black.pdf · Cartoon courtesy of “Computers and Intractability: A Guide to the Theory of NP-Completeness” by M. Garey and D. Johnson “I

msort([42, 3, 1, 6, 5, 2, 7])

msort([42, 3, 1]) msort([6, 5, 2, 7])

msort([42]) msort([3, 1]) msort([6, 5]) msort([2, 7])

[42]

msort([3])msort([1])

[3] [1]

[1,3]

[1,3,42] [2, 5, 6, 7]

[1, 2, 3, 5, 6, 7, 42]

Page 19: The CS 5 Timesjulie/cs5/f18/Lecture07Black.pdf · Cartoon courtesy of “Computers and Intractability: A Guide to the Theory of NP-Completeness” by M. Garey and D. Johnson “I

How “Efficient” Is Mergesort?

Page 20: The CS 5 Timesjulie/cs5/f18/Lecture07Black.pdf · Cartoon courtesy of “Computers and Intractability: A Guide to the Theory of NP-Completeness” by M. Garey and D. Johnson “I

How big a deal is this?

The Meder-O-Matic Supercomputer: 100 billion steps/second

n2 algorithm n log2 n algorithm

n = 108 11.5+ days

Page 21: The CS 5 Timesjulie/cs5/f18/Lecture07Black.pdf · Cartoon courtesy of “Computers and Intractability: A Guide to the Theory of NP-Completeness” by M. Garey and D. Johnson “I

How big a deal is this?

The Meder-O-Matic Supercomputer: 100 billion steps/second

n2 algorithm n log2 n algorithm

n = 108 11.5+ days 0.27 seconds

Page 22: The CS 5 Timesjulie/cs5/f18/Lecture07Black.pdf · Cartoon courtesy of “Computers and Intractability: A Guide to the Theory of NP-Completeness” by M. Garey and D. Johnson “I

“Easy” Problems

Sorting a list of n numbers: [42, 3, 17, 26, … , 100]

Multiplying two n x n matrices:

3 5 2 7 1 6 8 9 2 4 6 10 9 3 2 12

( ) 1 5 5 4 5 12 8 6 7 6 1 5 9 23 5 8

( ) = ( )n

n

n n

n

n log2 n

Page 23: The CS 5 Timesjulie/cs5/f18/Lecture07Black.pdf · Cartoon courtesy of “Computers and Intractability: A Guide to the Theory of NP-Completeness” by M. Garey and D. Johnson “I

“Easy” Problems

The Shortest Path Problem (i.e. “Google Maps”)

Edsgar Dijkstra

Page 24: The CS 5 Timesjulie/cs5/f18/Lecture07Black.pdf · Cartoon courtesy of “Computers and Intractability: A Guide to the Theory of NP-Completeness” by M. Garey and D. Johnson “I

“Easy” Problems

“Polynomial Time” = “Efficient”

n, n2, n3, n4, n5,…

How about something like n log2 n ?

The “class” P

sorting

matrix multiplication shortest paths

Page 25: The CS 5 Timesjulie/cs5/f18/Lecture07Black.pdf · Cartoon courtesy of “Computers and Intractability: A Guide to the Theory of NP-Completeness” by M. Garey and D. Johnson “I

“Hard” Problems

Snowplows of Northern Minnesota

Burrsburg

Frostbite City

Shiversville

Tundratown

FreezeapolisBrute-force? Greed?

Page 26: The CS 5 Timesjulie/cs5/f18/Lecture07Black.pdf · Cartoon courtesy of “Computers and Intractability: A Guide to the Theory of NP-Completeness” by M. Garey and D. Johnson “I

“Hard” Problems

The Traveling Salesperson Problem

New York

Moscow

Paris

San Francisco

Claremont

366

5625

1545

4664

5868

Brute Force? Greed?

2417

6060

2566

36275563

Page 27: The CS 5 Timesjulie/cs5/f18/Lecture07Black.pdf · Cartoon courtesy of “Computers and Intractability: A Guide to the Theory of NP-Completeness” by M. Garey and D. Johnson “I

The Hamiltonian Path Problem

Rome, GA

Athens, GA

Homer, GA

Damascus, GA

Bethlehem, GAThose are some peachy names!

William Rowan Hamilton

Page 28: The CS 5 Timesjulie/cs5/f18/Lecture07Black.pdf · Cartoon courtesy of “Computers and Intractability: A Guide to the Theory of NP-Completeness” by M. Garey and D. Johnson “I

n2 Versus 2n

The Meder-O-Matic performs 109 operations/sec

Meder-O-Matic

n2

2n

n!

n = 10 n = 30 n = 50 n = 70

100 < 1 sec

900 < 1 sec

2500 < 1 sec

1024 < 1 sec

109 1 sec

1015 11.6 days

4900 < 1 sec

1021 31,688 years

< 1 sec 1016 years 1057 years 1093 years

Page 29: The CS 5 Timesjulie/cs5/f18/Lecture07Black.pdf · Cartoon courtesy of “Computers and Intractability: A Guide to the Theory of NP-Completeness” by M. Garey and D. Johnson “I

Here’s an Idea!

n n2 n3 n5 2n n!

Size of largest problem solvable with “old” computer in one hour = S

Size of largest problem solvable with “new” twice-as-fast computer in one hour

2S 1.41S 1.26S 1.15S S+1 S

Let’s just buy a computer that’s twice as fast!

Page 30: The CS 5 Timesjulie/cs5/f18/Lecture07Black.pdf · Cartoon courtesy of “Computers and Intractability: A Guide to the Theory of NP-Completeness” by M. Garey and D. Johnson “I

Snowplows and Traveling Salesperson Revisited!

So are there polynomial time algorithms for the Snowplow and Travelling Salesperson, and Hamiltonian Path Problems?!

Travelling Salesperson Problem

Snowplow Problem

Hamiltonian Path Problem

NP-complete problems

Tens of thousands of other known problems go in this cloud!!

Page 31: The CS 5 Timesjulie/cs5/f18/Lecture07Black.pdf · Cartoon courtesy of “Computers and Intractability: A Guide to the Theory of NP-Completeness” by M. Garey and D. Johnson “I

Snowplows and Travelling Salesperson Revisited!

Travelling Salesperson Problem

Snowplow Problem

Hamiltonian Path Problem

NP-complete problems

Tens of thousands of other known problems go in this cloud!!

If a problem is NP-complete, it doesn’t necessarily mean that it can’t be solved in polynomial time. It does mean…

Page 32: The CS 5 Timesjulie/cs5/f18/Lecture07Black.pdf · Cartoon courtesy of “Computers and Intractability: A Guide to the Theory of NP-Completeness” by M. Garey and D. Johnson “I

“I can’t find an efficient algorithm. I guess I’m too dumb.”

Cartoon courtesy of “Computers and Intractability: A Guide to the Theory of NP-Completeness” by M. Garey and D. Johnson

Page 33: The CS 5 Timesjulie/cs5/f18/Lecture07Black.pdf · Cartoon courtesy of “Computers and Intractability: A Guide to the Theory of NP-Completeness” by M. Garey and D. Johnson “I

Cartoon courtesy of “Computers and Intractability: A Guide to the Theory of NP-Completeness” by M. Garey and D. Johnson

“I can’t find an efficient algorithm because no such algorithm is possible!”

Page 34: The CS 5 Timesjulie/cs5/f18/Lecture07Black.pdf · Cartoon courtesy of “Computers and Intractability: A Guide to the Theory of NP-Completeness” by M. Garey and D. Johnson “I

Cartoon courtesy of “Computers and Intractability: A Guide to the Theory of NP-Completeness” by M. Garey and D. Johnson

“I can’t find an efficient algorithm, but neither can all these famous people.”

Page 35: The CS 5 Timesjulie/cs5/f18/Lecture07Black.pdf · Cartoon courtesy of “Computers and Intractability: A Guide to the Theory of NP-Completeness” by M. Garey and D. Johnson “I

$1 million

Vinay Deolalikar

Page 36: The CS 5 Timesjulie/cs5/f18/Lecture07Black.pdf · Cartoon courtesy of “Computers and Intractability: A Guide to the Theory of NP-Completeness” by M. Garey and D. Johnson “I

What Is This?!

Page 37: The CS 5 Timesjulie/cs5/f18/Lecture07Black.pdf · Cartoon courtesy of “Computers and Intractability: A Guide to the Theory of NP-Completeness” by M. Garey and D. Johnson “I

Are There Problems That Are Even Harder Than NP-Complete?

Kryptonite problems?


Recommended