Algorithm classes Flashcards

1
Q

SAT language

A

}לפסוק Φ בצורת CNF קיימת השמה מספקת SAT={Φ|

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

Algorithm to solve SAT given algorithm to decide SAT A

A

For every Xi in the cnf, declare it as true and check if A still returns true. If so than it is True, if not than false.

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

The P class

A

A language L can be decided using an algorithm A in polynomial time.

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

The NP class

A

You can validate if there is a solution to the problem with an algorithm a and the original input alongside some additional input (usually the solution) in polynomial time.

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

Hamilton circuit problem

A

Given a graph and a set of edges we can validate in polynomial time if there is a Hamilton cycle or not (by checking if the edges go through all the nodes once)

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

Traveling salesman problem

A

Given a graph, a path in it and a target cost k, We can check if the input is a solution that does not exceed 10.

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

Partition problem

A

Given a group of numbers, find a partition of the group into two so that the new groups sums are equal.
Given a group and a possible partition it is easy to validate the solution by just checking if it is correct.

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

Given an algorithm A which decides the partition problem, create an algorithm to find the partition

A

Start by adding any two items, x, y in the group into one. Now you have a smaller group, run A on it. If it returns true, then you know that x and y are In the same group. Else, they are separate. Do this until you are left with two items in the group.

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

Knapsack problem

A

Given a backpack with volume v, put in it the items which add up to the biggest value.
Given a backpack’s volume, a group of item and a target price of k, we can easily check that all is valid.

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

Integer Linear Programming

A

Given a set of constraints that are translated into a set of equations, solve the equations so that the solutions are integers. To the non integer problem there is a solution using the simplex algorithm in a “ok” time. A solution is easily validated that it doesn’t exceed a value k by just assigning the solution in the equations.

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

Perfect number problem

A

A perfect number is a number that is equal to the sum of all its dividers which are smaller than it.
In order to validate if number is perfect or not, you can take use of the decomposition into prime numbers. Then take use of a formula to calculate the sum of the decomposition S and see if S=2n (n is the tested number).
S = (1+P1+P1^2 +….P1^K1)…. (1+Pm+Pm^2 +….Pm^Km)

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

co-NP

A

{L | L~ ∈ NP}
P ⊆ NP
P ⊆ co-NP

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

P or NP: 2 color graph

A

P: given a graph it is easy to say if it is colorable or not, by just running a simulation and seeing if their is a contradiction.

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

P or NP: 3 color graph

A

NP and even NPC

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

P or NP: 2 SAT

A

P: given a CNF equation, just check

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