NP reference Flashcards

1
Q

SAT Definition

A

Determine if a boolean formula in CNF can be satisfied by assigning true/false values to its variables.

  • A CNF formula is an AND of clauses, each an OR of literals.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

SAT Input

A

Boolean formula with n variables and m clauses.

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

SAT Output

A

A satisfying assignment for each variable (or NO if none exists).

Verification: Check each clause to ensure at least one literal evaluates to true under the given assignment.
Runtime: O(nm) - must check all m clauses, each with up to n literals.

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

3SAT Definition

A

Case of SAT where each clause has at most 3 literals.

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

3SAT Input

A

Boolean formula, each clause with at most 3 literals.

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

3SAT Output

A

A satisfying assignment for each variable (or NO if none exists).

Verification: Check each clause to ensure at least one literal evaluates to true.
Runtime: O(m) - checking each clause takes constant time (maximum 3 literals per clause).

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

Clique Definition

A

Determine if a graph has a clique of size k.

  • A subset of vertices where every pair is connected by an edge.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Clique Input

A

Undirected G = (V, E); integer k.

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

Clique Output

A

A set of k vertices forming a clique (or NO if none exists).

Verification: Check that every pair of vertices in the solution set has an edge between them.
Runtime: O(n²) - need to check all pairs of vertices in the solution.

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

Independent Set Definition

A

Determine if a graph has an independent set of size k.

  • A subset of k vertices with no edge between them.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Independent Set Input

A

Undirected G = (V, E); integer k.

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

Independent Set Output

A

A set of k vertices forming an independent set (or NO if none exists).

Verification: Check that no pair of vertices in the solution set has an edge between them.
Runtime: O(n²) - need to check all pairs of vertices in the solution.

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

Vertex Cover Definition

A

Determine if a graph has a vertex cover of size at most k.

  • A subset of vertices such that every edge in E has at least one endpoint in the subset.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Vertex Cover Input

A

Undirected G = (V, E); integer k.

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

Vertex Cover Output

A

A set of ≤ k vertices forming a vertex cover (or NO if none exists).

Verification: Check that every edge in the graph has at least one endpoint in the solution set.
Runtime: O(m) - need to check each edge in the graph.

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

Rudrata Path Definition

A

Determine if a graph has a path from vertex s to vertex t that visits each vertex exactly once.

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

Rudrata Path Input

A

Graph G = (V, E); Two vertices in V: s and t.

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

Rudrata Path Output

A

A path from s to t visiting every vertex exactly once (or NO if none exists).

Verification: Check that the path starts at s, ends at t, visits all vertices, and each pair of consecutive vertices in the path has an edge between them.
Runtime: O(n) - need to check each vertex appears exactly once and consecutive vertices are connected.

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

Rudrata Cycle Definition

A

Determine if a graph has a cycle that visits each vertex exactly one time.

20
Q

Rudrata Cycle Input

A

Graph G = (V, E).

21
Q

Rudrata Cycle Output

A

A cycle visiting every vertex exactly once (or NO if none exists).

Verification: Check that the sequence forms a valid cycle (last vertex connects to first), contains all vertices exactly once, and each pair of consecutive vertices has an edge between them.
Runtime: O(n) - need to check each vertex appears exactly once and consecutive vertices are connected.

22
Q

TSP Definition

A

Determine if a complete weighted graph has a tour visiting all vertices with total weight at most a bound.

23
Q

TSP Input

A

Complete graph G = (V, E); edge weights w(i, j); Bound B.

24
Q

TSP Output

A

A tour with total weight ≤ B (or NO if none exists).

Verification: Check that the tour visits all vertices exactly once, returns to the starting vertex, and has total weight ≤ B.
Runtime: O(n) - need to check each vertex appears exactly once and calculate the total weight.

25
Q

Subset Sum Definition

A

Determine if there exists a subset of a given set of integers that sums exactly to a target value.

26
Q

Subset Sum Input

A

A set of integers S = {a₁, a₂, …, aₙ}; A target integer t.

27
Q

Subset Sum Output

A

A subset of S summing to t (or NO if none exists).

Verification: Sum the integers in the proposed subset and check if the sum equals t.
Runtime: O(n log t) - need to sum at most n integers, each requiring O(log t) space.

28
Q

ILP Definition

A

Determine if there exists an integer solution to a system of linear constraints that achieves a target objective value.

29
Q

ILP Input

A

Objective function C^T x, constraints Ax ≤ b, x integer; Target value k.

30
Q

ILP Output

A

An integer vector x satisfying the constraints and achieving objective value ≥ k (or NO if none exists).

Verification: Check that x contains integers, Ax ≤ b is satisfied, and C^T x ≥ k.
Runtime: O(mn) where A is an m×n matrix - need to verify all constraints.

31
Q

ZOE Definition

A

Determine if there exists a 0-1 assignment to variables that satisfies a system of linear equations where each equation sums to 1.

32
Q

ZOE Input

A

System Ax = 1, where A is an m×n 0-1 matrix, x is a 0-1 vector.

33
Q

ZOE Output

A

A 0-1 vector x satisfying Ax = 1 (or NO if none exists).

Verification: Check that x contains only 0s and 1s, and Ax = 1.
Runtime: O(mn) - need to multiply the m×n matrix A by the n-vector x.

34
Q

3D Matching Definition

A

Determine if a set of triples can be selected to cover three sets exactly once.

35
Q

3D Matching Input

A

Three disjoint sets X, Y, Z, each of size n; A set of triples T ⊆ X×Y×Z.

36
Q

3D Matching Output

A

A subset of n disjoint triples covering X∪Y∪Z (or NO if none exists).

Verification: Check that the solution contains exactly n triples, each element of X, Y, and Z appears in exactly one triple.
Runtime: O(n) - need to verify each element appears in exactly one triple.

37
Q

k-Colorings Definition

A

Determine if each adjacent vertices get different colors

38
Q

k-Colorings Input

A

undirected G=(V,E) & integer k > 0

39
Q

k-Colorings Output

A

Assignments of color for each v in V

Verification: Check that for all (x,y) in E that color(x) != color(y)
Runtime: O(n+m) to walk the adjacency list to verify

40
Q

if a NP-Complete problem can be solved in poly-time, then…

A

All problems in NP can be solved in poly-time.

41
Q

[3SAT]
When reducing SAT -> 3SAT, each new k-3 variables are unique for each clause

42
Q

[SAT to 3SAT]
Runtime to create additional clauses during input transform

A

O(mn)

There are m clauses with at most n literals

43
Q

[3SAT]
Runtime to return the output

A

O(mn)

There are at most O(m(n-3)) new variables, so removing them takes at most O(m(n-3)+n) (ie. new vars + old vars) which simplify to O(mn)

44
Q

Examples of P problems

A

2SAT, Horn SAT
MST
Shortest Path
Bipartite matching
Unary Knapsack
IS on trees
LP
Euler path
Minimum cut

45
Q

Diff between Euler vs Rudrata Path

A

Euler - path that uses every edge of a graph exactly once

Rudrata - visits every vertex of a graph exactly once

46
Q

[Hitting Set]
Input Transformation runtime