Announcements Presentations tomorrow Updated instructions on - - PowerPoint PPT Presentation

announcements
SMART_READER_LITE
LIVE PREVIEW

Announcements Presentations tomorrow Updated instructions on - - PowerPoint PPT Presentation

Announcements Presentations tomorrow Updated instructions on website Send name of who will do screen sharing Peer feedback forms Arrive early to Zoom call Get something to draw with PM6 posted Quiz 3 Office hours


slide-1
SLIDE 1

Announcements

  • Presentations tomorrow
  • Updated instructions on website
  • Send name of who will do screen sharing
  • Peer feedback forms
  • Arrive early to Zoom call
  • Get something to draw with
  • PM6 posted
  • Quiz 3
  • Office hours by appointment only this week
  • Elissa video
  • Course evaluations
  • Making your website public
slide-2
SLIDE 2

Coloring is Harder than You Think

CS 115 Computing for the Socio-Techno Web Brian Brubach

slide-3
SLIDE 3

Computer Science Theory

  • Ask questions about what is even possible
  • What problems can computers solve?
  • Time à How fast can be we solve them?
  • Space à Can we do it without using too much memory/space?
  • Approximation algorithms à If we can’t solve it or not fast enough, can we find

an approximate solution?

  • Often use worse case analysis, the hard instance of a problem
  • How are different problems related
  • Sometimes like going back to kindergarten
  • Topics include: counting and coloring
  • Today I’ll show you how to become a millionaire by coloring
  • When programming, it’s helpful to know if you’re trying to solve an

intractable/impossible problem

slide-4
SLIDE 4

Warm Up

  • What are the odds that two people living in the state of Maryland

have exactly the same number of hairs on their head?

slide-5
SLIDE 5

Warm Up

  • What are the odds that two people living in the state of

Massachusetts have exactly the same number of hairs on their head?

  • No beards! Only hairs on top of head!
  • Not including people who shave their heads!
slide-6
SLIDE 6

Warm Up

  • What are the odds that two people living in the state of

Massachusetts have exactly the same number of hairs on their head?

  • No beards! Only hairs on top of head!
  • Not including people who shave their heads!
  • Less than 200,000 hairs on any human head
  • Roughly 6.8 million people in Massachusetts
slide-7
SLIDE 7

Pigeonhole Principle

  • If you have 𝑜 + 1 pigeons and 𝑜 pigeonholes, at least two pigeons

will share a hole

slide-8
SLIDE 8

Pigeonhole Principle

  • If you have 𝑜 + 1 pigeons and 𝑜 pigeonholes, at least two pigeons

will share a hole

slide-9
SLIDE 9

Pigeonhole Principle

  • If you have 𝑜 + 1 pigeons and 𝑜 pigeonholes, at least two pigeons

will share a hole

slide-10
SLIDE 10

Pigeonhole Principle

  • If you have 𝑜 + 1 pigeons and 𝑜 pigeonholes, at least two pigeons

will share a hole

slide-11
SLIDE 11

Pigeonhole Principle

  • If you have 𝑜 + 1 pigeons and 𝑜 pigeonholes, at least two pigeons

will share a hole

slide-12
SLIDE 12

Pigeonhole Principle

  • If you have 𝑜 + 1 pigeons and 𝑜 pigeonholes, at least two pigeons

will share a hole

slide-13
SLIDE 13

The Map Coloring Problem

  • What is the maximum number of colors needed to color any map so

that no neighboring countries/states/counties are the same color?

  • I.e., how many different crayons do you need to buy to color any map?
slide-14
SLIDE 14

One extra rule…

slide-15
SLIDE 15

One extra rule… No Alaskas!

  • Each country must be contiguous (one connected space)
slide-16
SLIDE 16

Color the maps with as few colors as possible

  • Neighboring countries can’t be the same color
  • Corners touching doesn’t count as neighboring
  • How many colors do you need?
slide-17
SLIDE 17

How many colors needed?

slide-18
SLIDE 18

How many colors needed?

slide-19
SLIDE 19

How many colors needed?

slide-20
SLIDE 20

How many colors needed?

slide-21
SLIDE 21

How many colors needed?

slide-22
SLIDE 22

How many colors needed?

slide-23
SLIDE 23

How many colors needed?

slide-24
SLIDE 24

How many colors needed?

slide-25
SLIDE 25

How many colors needed?

slide-26
SLIDE 26

How many colors needed?

slide-27
SLIDE 27

How many colors needed?

slide-28
SLIDE 28

How many colors needed?

slide-29
SLIDE 29

How many colors needed?

slide-30
SLIDE 30

How many colors needed?

slide-31
SLIDE 31

How many colors needed?

slide-32
SLIDE 32

Need at least 4 colors! Why?

slide-33
SLIDE 33

Draw a map that needs as many colors as possible

  • Neighboring countries can’t be the same color
  • Corners touching doesn’t count as neighboring
  • No Alaskas
  • Don’t draw too many countries
  • Can you draw a map that requires 3, 4, 5, 6, or more colors?
slide-34
SLIDE 34

History of Map Coloring

  • 1852 Francis Guthrie
  • Coloring the counties of England
  • Noticed he needed four colors, but not more
  • Asked: is four enough to color any map or do we need more?
slide-35
SLIDE 35

History of Map Coloring

  • 1852 Francis Guthrie
  • Coloring the counties of England
  • Noticed he needed four colors, but not more
  • Asked: is four enough to color any map or do we need more?
  • 1879 Alfred Kempe proves the Four-Color Theorem
  • Only need four colors to color any map
slide-36
SLIDE 36

History of Map Coloring

  • 1852 Francis Guthrie
  • Coloring the counties of England
  • Noticed he needed four colors, but not more
  • Asked: is four enough to color any map or do we need more?
  • 1879 Alfred Kempe proves the Four-Color Theorem
  • Only need four colors to color any map
  • 1880 Peter Tait finds another proof
slide-37
SLIDE 37

History of Map Coloring

  • 1852 Francis Guthrie
  • Coloring the counties of England
  • Noticed he needed four colors, but not more
  • Asked: is four enough to color any map or do we need more?
  • 1879 Alfred Kempe proves the Four-Color Theorem
  • Only need four colors to color any map
  • 1880 Peter Tait finds another proof
  • 1890 Percy John Heawood shows that Kempe’s proof was wrong!
slide-38
SLIDE 38

History of Map Coloring

  • 1852 Francis Guthrie
  • Coloring the counties of England
  • Noticed he needed four colors, but not more
  • Asked: is four enough to color any map or do we need more?
  • 1879 Alfred Kempe proves the Four-Color Theorem
  • Only need four colors to color any map
  • 1880 Peter Tait finds another proof
  • 1890 Percy John Heawood shows that Kempe’s proof was wrong!
  • 1891 Julius Petersen shows that Tait’s proof was wrong!
slide-39
SLIDE 39

History of Map Coloring

  • 1852 Francis Guthrie
  • Coloring the counties of England
  • Noticed he needed four colors, but not more
  • Asked: is four enough to color any map or do we need more?
  • 1879 Alfred Kempe proves the Four-Color Theorem
  • Only need four colors to color any map
  • 1880 Peter Tait finds another proof
  • 1890 Percy John Heawood shows that Kempe’s proof was wrong!
  • 1891 Julius Petersen shows that Tait’s proof was wrong!
  • 1976 Kenneth Appel and Wolfgang Haken
  • Any map (with no Alaskas) can be colored with four colors (no maps require five

colors)

  • Checked 1,936 small maps using computer assistance
  • Proof is 400+ pages long (Checked by Dorothea Blostein)
slide-40
SLIDE 40

4-coloring of US

slide-41
SLIDE 41

4-coloring of US

slide-42
SLIDE 42

4-coloring of World

slide-43
SLIDE 43

4-coloring of World

slide-44
SLIDE 44

Including the ocean

slide-45
SLIDE 45

What about maps that only require three colors?

  • Some maps (e.g. Australia) only require three colors
  • Suppose someone hands you a map and asks, “Can this be colored

with three colors or does it need four?”

  • What would you do?
slide-46
SLIDE 46

What about maps that only require three colors?

  • Some maps (e.g. Australia) only require three colors
  • Suppose someone hands you a map and asks, “Can this be colored

with three colors or does it need four?”

  • What would you do?
  • Try all possible 3-colorings?
slide-47
SLIDE 47

What about maps that only require three colors?

  • Some maps (e.g. Australia) only require three colors
  • Suppose someone hands you a map and asks, “Can this be colored

with three colors or does it need four?”

  • What would you do?
  • Try all possible 3-colorings?
  • There are 3% ways to color an 𝑜 country map with 3 colors (3&' > 1 million)
slide-48
SLIDE 48

What about maps that only require three colors?

  • Some maps (e.g. Australia) only require three colors
  • Suppose someone hands you a map and asks, “Can this be colored

with three colors or does it need four?”

  • What would you do?
  • Try all possible 3-colorings?
  • There are 3% ways to color an 𝑜 country map with 3 colors (3&' > 1 million)
  • The answer is unknown!
slide-49
SLIDE 49

Becoming a millionaire by coloring

  • Algorithm: simply a method or set of instructions for solving a

problem

  • E.g. a cake recipe is an algorithm for baking a cake
slide-50
SLIDE 50

Becoming a millionaire by coloring

  • Algorithm: simply a method or set of instructions for solving a

problem

  • E.g. a cake recipe is an algorithm for baking a cake
  • Suppose you could design algorithm that answers the question, “Can

this map be colored with three colors or does it need four?”

slide-51
SLIDE 51

Becoming a millionaire by coloring

  • Algorithm: simply a method or set of instructions for solving a

problem

  • E.g. a cake recipe is an algorithm for baking a cake
  • Suppose you could design algorithm that answers the question, “Can

this map be colored with three colors or does it need four?”

  • This would solve one of the seven Millennium Prize Problems which

each carry a $1 million prize

slide-52
SLIDE 52

Becoming a millionaire by coloring

  • Algorithm: simply a method or set of instructions for solving a

problem

  • E.g. a cake recipe is an algorithm for baking a cake
  • Suppose you could design algorithm that answers the question, “Can

this map be colored with three colors or does it need four?”

  • This would solve one of the seven Millennium Prize Problems which

each carry a $1 million prize

  • Coloring is related to the P vs. NP problem
  • Only one of the other problems (Poincaré conjecture) has been solved, but they

didn’t accept the prize money

slide-53
SLIDE 53

P vs. NP (roughly)

  • Is P = NP? à One of the biggest open problems in computer science
  • P à the class of problems that a computer can solve efficiently
  • Shortest path à find the shortest route between two cities
  • NP à the class of problems where we can efficiently verify a solution
  • Traveling Salesperson à Is there a route shorter than 1,000 miles that visits

every city on a list?

  • If you give me a route, I can check it quickly
  • By efficient, we mean roughly that the running time is not

exponential in the size of the problem

  • E.g. taking 3% time to color 𝑜 countries is not efficient
  • The big question à If we can verify a solution to a problem quickly,

does that imply we can also solve it quickly?

slide-54
SLIDE 54

NP-complete

  • NP-complete à Special class of problems
  • Known to be in NP
  • Not known if they are in P
  • Can all be transformed into each other à If you can solve one efficiently, you

can solve any of them efficiently

  • Contains many fundamental important problems and even Sudoku
  • All hard problems for computers to solve
  • In practice, we can sometimes solve these problems efficiently with “heuristics”
  • Heuristics are essentially algorithms that are not guaranteed to always work
  • Can also get approximate solutions
slide-55
SLIDE 55

Is P = NP? What would this mean?

  • Most computer scientists believe P is not equal to NP
  • However, we haven’t been able to prove this
  • P = NP would imply many problems are much easier to solve than we

think

  • Downside of P = NP à our cryptography for secure internet

transactions fails

  • Upside of P = NP à many hard problems solvable from traveling

salesperson to protein structure prediction

  • Theoretically, could then easily solve the other remaining Millennium Prize

Problems

slide-56
SLIDE 56

Graph Theory

  • Graph à set of “vertices” (dots) with “edges” (lines) connecting

them

  • Graph coloring problem à Assign a color to each vertex such that

vertices sharing an edge have different colors

Not allowed to be same color!

slide-57
SLIDE 57

Reductions: Transforming Problems into Each Other

  • Notice that if we can solve graph coloring, then we can solve map

coloring

slide-58
SLIDE 58

Reductions: Transforming Problems into Each Other

  • Notice that if we can solve graph coloring, then we can solve map

coloring

slide-59
SLIDE 59

Reductions: Transforming Problems into Each Other

  • Notice that if we can solve graph coloring, then we can solve map

coloring

  • What other problems can we solve with graph coloring?
slide-60
SLIDE 60

Reductions: Transforming Problems into Each Other

  • Notice that if we can solve graph coloring, then we can solve map

coloring

  • What other problems can we solve with graph coloring?
  • Seating charts
  • Final exam scheduling on the fewest possible days
  • Any other NP-complete problem à Traveling salesperson, facility location,

protein folding, etc. Alanna Edward Tammie Bharat Mikhail Safira Lea Edges represent drama between two students Vertices are students to seat at tables Each “color” is a table to seat students at

slide-61
SLIDE 61

Takeaways

  • There are many problems that we think computers can’t solve

efficiently

  • Can sometimes still solve them in practice using heuristics or

approximations

  • Heuristic à Algorithm that is not guaranteed to work
  • Approximation à Algorithm that is guaranteed to work, but only gives an

approximate solution

  • When trying to improve a program, you should make sure that what

you’re doing is possible

  • Many seemingly different problems can be transformed into each
  • ther through reductions
  • What is P vs NP?
  • How hard is coloring?
slide-62
SLIDE 62

Time complexity