Sept 29
Sept 29
1
Example: A Scheduling Problem
Now if 𝑠𝑠2 co-exist with all others that follow it, 𝑔𝑔2 with
earlier or same end time can also!
So S ′ = (𝑔𝑔1 , 𝑔𝑔2 , s3 , s4 , … ) is valid (optimal).
Like this we can obtain more optimal solutions and end with
the greedy solution without ever loosing optimality.
Formal proof by contradiction:
Suppose 𝐺𝐺 is NOT optimal.
Pick an optimal 𝑆𝑆 which is closest (max |𝑆𝑆 ∩ 𝐺𝐺|) to 𝐺𝐺.
𝑆𝑆 ≠ 𝐺𝐺
We can modify 𝑆𝑆 to 𝑆𝑆𝑆 so that:
𝑆𝑆𝑆 is also optimal & 𝑆𝑆 ′ ∩ 𝐺𝐺 ≥ 𝑆𝑆 ∩ 𝐺𝐺
4 Contradiction!
Set Cover
𝐼𝐼 = 𝑆𝑆𝑖𝑖 , 𝑖𝑖 = 1: 𝑚𝑚 & ∪𝑘𝑘=1:𝑚𝑚 𝑆𝑆𝑘𝑘 = 𝐵𝐵, 𝑆𝑆𝑘𝑘 ≠ {𝜙𝜙}
Minimize 𝐼𝐼𝑠𝑠 𝑜𝑜𝑜𝑜 |𝐽𝐽| ≤ 𝑚𝑚 , 𝐼𝐼𝑠𝑠 = 𝑆𝑆𝑖𝑖 ,∪𝑖𝑖 𝑆𝑆𝑖𝑖 = 𝐵𝐵 , 𝐽𝐽 = {𝑖𝑖,∪𝑖𝑖 𝑆𝑆𝑖𝑖 = 𝐵𝐵}
Example: 𝐵𝐵 is a universal set of topics covered by 𝑚𝑚 available ALGO
courses. 𝑆𝑆𝑗𝑗 is the set of topics covered by the 𝑗𝑗𝑡𝑡𝑡 ALGO course. Taking
minimum number of which ALGO courses will allow us to learn all
the topics being covered by all the 𝒎𝒎 of them?
Courses
More
than 1
optimal! Topics
5
A graph? (number of points (n) = number of sets (m))
Example: 𝐵𝐵 is a universal set of 𝑛𝑛 towns. 𝑆𝑆𝑗𝑗 is the set of towns (that will be)
covered by the school of 𝑗𝑗𝑡𝑡𝑡 town (𝑚𝑚 = 𝑛𝑛, symmetric, not transitive). Which
minimum number of schools can cover all the 𝑛𝑛 towns. [Vertex Cover]
A school in a town will cover another adjacent (edge) town
6
Algo Skeleton:
1. Set 𝐽𝐽 = 𝜙𝜙
2. While ∪𝑖𝑖∈𝐽𝐽 𝑆𝑆𝑖𝑖 ≠ 𝐵𝐵: Pick 𝑖𝑖 ∉ 𝐽𝐽 (𝑆𝑆𝑖𝑖 ∈ 𝐼𝐼\J) and add to 𝐽𝐽
3. Return 𝐽𝐽
Strategy?
Chose the largest uncovered set? max |𝑆𝑆𝑖𝑖 \∪𝑘𝑘∈𝐽𝐽 𝑆𝑆𝑘𝑘 |
𝑖𝑖∉𝐽𝐽