Week 1 (P vs NP, Stable Matching) Flashcards

(22 cards)

1
Q

What is the class P?

A

The class of problems solvable in polynomial time by a deterministic TM

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the class NP?

A

The class of problems verifiable in polynomial time by a deterministic TM but solvable in polynomial time by a non-deterministic TM

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a reduction?

A

A reduction transforms a problem A into a problem B such that if you can solve problem B efficiently you can solve problem A efficiently.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the notation for a polytime redutcion?

A

Y ≤p X

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a NP-hard problem?

A

A problem is NP-hard if for all problems Y ∈ NP, Y ≤p X

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do we prove a problem is NP-hard?

A

By reducing any known NP-hard problem such that SAT ≤p X

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the Cook-Levin theorem?

A

The Cook-Levin theorem states CNF-Satisfiability (SAT) is NP-hard

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do we prove almost-SAT?

A

Given a CNF formula with N variables and M clauses, Almost-SAT satisfies exactly M-1 clauses.

For an instance of SAT I, Almost SAT I’ = I ∧ (y) ∧ (ȳ).
If all clauses of I are satisfiable, then all but one clause of I’ is satisfiable.

This reduction works in polynomial time as we have M+2 clauses.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What instances of SAT can be proved in polynomial time?

A

1-SAT and 2-SAT

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the max clause length for SAT?

A

2N as each variable can be y or ȳ

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How can we prove the independent set is NP-hard?

A

By taking an instance I of 3-SAT and building a graph G of 3M vertices. We add edges as conflicts to ensure every variable is not True and False.

I is satisfiable iff G has an independent set of size M.

Takes (N+M)^O(1) time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is said about NP-hard problems if we assume P != NP?

A

A NP-hard problem cannot have an algorithm that is both always correct and runs in polynomial time.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is CNF?

A

A conjunction of clauses where each clause is a disjunction of literals
(and of ors)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the brute force time for SAT?

A

Checking 2^N truth assignments for N variables and M clauses

=> O(2^N . N . M)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the independent set problem?

A

Given an undirected graph G=(V,E) of n vertices, a set X has no pair of vertices that form an edge

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the stable matching problem?

A

Aims to find a stable matching where there are no unstable pairs.

17
Q

What is an unstable matching?

A

An pair is unstable if there is a higher preference to their current partner.

18
Q

What is the Gale-Shapley algorithm?

A

Initially all hospitals and students are free
while There is a hospital which is free and hasn’t made an offer to every
student do
Choose such a hospital h
Let s be highest ranked student to which h hasn’t made an offer yet
if s is free then
(s, h) are matched
else
s is currently matched to some hospital h′
if s prefers h′ to h then
h remains free
else
s prefers h to their current match h′
(s, h) get matched and h′ becomes free
end if
end if
end while

19
Q

What is the output of the Gale-Shapley algorithm?

A

Gale-Shapley always returns a stable matching in O(N^2) time

20
Q

What happens to the offers of students vs hospitals as the Gale-Shapley algorithm progresses?

A

The side that sends out offers, i.e. the hospitals, send out worse offers as the algorithm progresses but the side that receives offers, i.e. the students, receive better offers as the algorithm progresses.

21
Q

Argue the correctness and running time of the Gale-Shapley algorithm

A

The algorithm is correct as if there is a hospital that is free, then there is a student that hasn’t received an offer yet.

22
Q

Prove that the Gale-Shapley algorithm always returns a stable matching

A

If we assume Gale-Shapley doesn’t return a stable match, let (h,s) and (h’,s’) be an allocation made.

The last match was (h,s)

If h didn’t make an offer to s’ before s, then h prefers s to s’ => contradiction

If h did make an offer to s’ before s, then h was rejected by s’ in favour of a different hospital => contraditcion