CS 4102 Algorithms Fall 2020 1 Reductions Algorithm

  • Slides: 33
Download presentation
CS 4102 Algorithms Fall 2020 1

CS 4102 Algorithms Fall 2020 1

Reductions • Algorithm technique of supreme ultimate power • Convert instance of problem A

Reductions • Algorithm technique of supreme ultimate power • Convert instance of problem A to an instance of Problem B • Convert solution of problem B back to a solution of problem A 2

Mac. Gyver’s Reduction Problem we do know how to solve Problem we don’t know

Mac. Gyver’s Reduction Problem we do know how to solve Problem we don’t know how to solve Opening a door Aim duct at door, insert keg Lighting a fire How? Keg cannon battering ram Put fire under the Keg Reduction Alcohol, wood, matches 3

In General: Reduction Problem we do know how to solve Problem we don’t know

In General: Reduction Problem we do know how to solve Problem we don’t know how to solve Injective: any instance of A can be mapped to some instance of B. Reduction 4

Bipartite Matching Reduction Problem we do know how to solve Problem we don’t know

Bipartite Matching Reduction Problem we do know how to solve Problem we don’t know how to solve Bipartite Matching Max Flow 2 3 1 1 1 11 1 1 1/1 1/1 1 2 3 Ford Fulkerson 1/1 1/1 2 1 0 2 1/1 1 0 3 Reduction 3 2 1 1/1 0/1 0/1 1/1 0/1 3 2 1 1 2 0 2 3 1 1 Must show (prove): 2 1) how to make construction 2) Why it works 1 5

Temp Agency Big Picture Max Bipartite Matching Temp Agency Max Flow 1 1 11

Temp Agency Big Picture Max Bipartite Matching Temp Agency Max Flow 1 1 11 2 3 1 1 3 3 2 1 2 3 Ford Fulkerson 1/1 Consolidate duplicates Reduction 1/1 1/1 0/1 0/1 1/1 1/1 0 2 1 1/1 0 3 Reduction 2 1 1 2 0 2 3 1 1 1 2 6

Reductions for New Algorithms • Create an algorithm for a new problem by using

Reductions for New Algorithms • Create an algorithm for a new problem by using one you already know! • More algorithms = More opportunities! • The problem you reduced to could itself be solved using a reduction!

Another use of Reductions An algorithm for A Reduction 8

Another use of Reductions An algorithm for A Reduction 8

Worst-case Lower-Bound Using Reductions 2 1 • 5 4 6 7 3 8

Worst-case Lower-Bound Using Reductions 2 1 • 5 4 6 7 3 8

Reductions for Lower-Bounds Problem we want to show is “Hard” Problem we know is

Reductions for Lower-Bounds Problem we want to show is “Hard” Problem we know is “Hard” then this can’t be fast! and this must be slow, If this is quick, “Hard” means this must be slow and this is quick, Reduction 10

Reductions for Lower-Bound on CPP Closest Pair of Points Reduction 11

Reductions for Lower-Bound on CPP Closest Pair of Points Reduction 11

A “Hard” Problem: Element Uniqueness • 113 901 555 512 245 800 018 121

A “Hard” Problem: Element Uniqueness • 113 901 555 512 245 800 018 121 True 103 801 401 323 255 323 999 101 False

Reductions for Lower-Bound on CPP Closest Pair of Points Reduction 13

Reductions for Lower-Bound on CPP Closest Pair of Points Reduction 13

Mapping Instances of Element Uniqueness to CPP Running time? • 9, 9 8, 8

Mapping Instances of Element Uniqueness to CPP Running time? • 9, 9 8, 8 5 7 9 8 6 3 6 9 7, 7 5, 5 How to we find the answer to Element Uniqueness from Closest Pair? 6, 6 3, 3 Check if closest pair’s distance is 0 Running time?

Reductions for Lower-Bound on CPP Element Uniqueness 5 7 9 8 6 3 6

Reductions for Lower-Bound on CPP Element Uniqueness 5 7 9 8 6 3 6 9 Closest Pair of Points Is closest distance > 0? Reduction 15

Reductions for Lower-Bound on CPP Element Uniqueness 5 7 9 8 6 3 6

Reductions for Lower-Bound on CPP Element Uniqueness 5 7 9 8 6 3 6 9 Closest Pair of Points Is closest distance > 0? Reduction 16

3 -Sum • 20 8 -30 -10 2 80 19 22 20 -4 30

3 -Sum • 20 8 -30 -10 2 80 19 22 20 -4 30 -2 -1 0 40 -3

3 -Sum • 20 8 -30 -10 -2 80 19 22 20 -4 30

3 -Sum • 20 8 -30 -10 -2 80 19 22 20 -4 30 -2 -1 0 40 -3

3 -Sum • 20 8 -30 -10 -2 80 19 22 20 -4 30

3 -Sum • 20 8 -30 -10 -2 80 19 22 20 -4 30 -2 -1 0 40 -3

20 8 -30 -10 -2 80 19 22 20 -4 30 -2 -1 0

20 8 -30 -10 -2 80 19 22 20 -4 30 -2 -1 0 40 -3 -30 -10 -2 8 19 20 22 80 -4 -3 -2 -1 0 20 30 40

20 8 -30 -10 -2 80 19 22 20 -4 30 -2 -1 1

20 8 -30 -10 -2 80 19 22 20 -4 30 -2 -1 1 40 -3 -30 -10 -2 8 19 20 22 80 -4 -3 -2 -1 1 20 30 40

3 -Collinear • Given a collection of points, are there any 3 that are

3 -Collinear • Given a collection of points, are there any 3 that are collinear but not vertically aligned? • How quickly can you solve this?

3 -Collinear •

3 -Collinear •

Reduction 24

Reduction 24

Using 3 -Collinear to solve 3 -Sum • Reduce 3 -Sum to 3 -Collinear

Using 3 -Collinear to solve 3 -Sum • Reduce 3 -Sum to 3 -Collinear • Given an instance of 3 -Sum (a set of numbers), produce an instance of 3 -Collinear (a set of points) such that: – If three numbers sum to 0, the set of points has 3 collinear (but not vertical) points – If no three numbers sum to 0, the set of points does not have 3 collinear (but not vertical) points

Mapping •

Mapping •

3 -Sum if and only if 3 -Collinear •

3 -Sum if and only if 3 -Collinear •

3 -Sum Hard •

3 -Sum Hard •

3 -Sum Solution for 3 -Sum Reduction 29

3 -Sum Solution for 3 -Sum Reduction 29

Segment Partition • Given a collection of line segments, is there a line which

Segment Partition • Given a collection of line segments, is there a line which splits them into 2 non-empty sets (without intersecting any segment)? How could we show Segment Partition is 3 -Sum Hard?

Segment Partition is 3 -Sum Hard 3 -Collinear 3 -Sum 20 8 -30 -10

Segment Partition is 3 -Sum Hard 3 -Collinear 3 -Sum 20 8 -30 -10 -2 80 19 22 20 8 -30 -10 2 80 19 22 Reduction Segment Partition Reduction 31

Why Do We Care?

Why Do We Care?

More 3 -Sum Hard Problems • Given a set of points on a plane,

More 3 -Sum Hard Problems • Given a set of points on a plane, find the smallest triangle formed by any 3 • Given a set of triangles and a given triangle, does the set cover the given? • Given a set of line segments and a “robot” (line segment), can the “robot” navigate through the segments? • Given two polygons, can one translated to fit inside the other?