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 Coloring is Harder than You Think
CS 115 Computing for the Socio-Techno Web Brian Brubach
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 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 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 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 Pigeonhole Principle
- If you have 𝑜 + 1 pigeons and 𝑜 pigeonholes, at least two pigeons
will share a hole
SLIDE 8 Pigeonhole Principle
- If you have 𝑜 + 1 pigeons and 𝑜 pigeonholes, at least two pigeons
will share a hole
SLIDE 9 Pigeonhole Principle
- If you have 𝑜 + 1 pigeons and 𝑜 pigeonholes, at least two pigeons
will share a hole
SLIDE 10 Pigeonhole Principle
- If you have 𝑜 + 1 pigeons and 𝑜 pigeonholes, at least two pigeons
will share a hole
SLIDE 11 Pigeonhole Principle
- If you have 𝑜 + 1 pigeons and 𝑜 pigeonholes, at least two pigeons
will share a hole
SLIDE 12 Pigeonhole Principle
- If you have 𝑜 + 1 pigeons and 𝑜 pigeonholes, at least two pigeons
will share a hole
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
One extra rule…
SLIDE 15 One extra rule… No Alaskas!
- Each country must be contiguous (one connected space)
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
How many colors needed?
SLIDE 18
How many colors needed?
SLIDE 19
How many colors needed?
SLIDE 20
How many colors needed?
SLIDE 21
How many colors needed?
SLIDE 22
How many colors needed?
SLIDE 23
How many colors needed?
SLIDE 24
How many colors needed?
SLIDE 25
How many colors needed?
SLIDE 26
How many colors needed?
SLIDE 27
How many colors needed?
SLIDE 28
How many colors needed?
SLIDE 29
How many colors needed?
SLIDE 30
How many colors needed?
SLIDE 31
How many colors needed?
SLIDE 32
Need at least 4 colors! Why?
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 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 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 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 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 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 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
4-coloring of US
SLIDE 41
4-coloring of US
SLIDE 42
4-coloring of World
SLIDE 43
4-coloring of World
SLIDE 44
Including the ocean
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?”
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 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 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 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 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 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 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 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 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 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 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 Reductions: Transforming Problems into Each Other
- Notice that if we can solve graph coloring, then we can solve map
coloring
SLIDE 58 Reductions: Transforming Problems into Each Other
- Notice that if we can solve graph coloring, then we can solve map
coloring
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 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 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
Time complexity