Assignment 2
Assignment 2
3 Given a decision vertex-cover problem instances 𝐺(𝑉, 𝐸, 𝑘), where 𝑉 = {1,2,3,4,5,6,7} and PO2,PO4 L5
𝐸 = {(1,2), (1,3), (2,3), (1,4), (2,5), (3,6), (4,6), (4,5), (5,7), (6,7)}, 𝑘 = 3. Find the
decision set-cover problem instances (i.e., V, subsets of V and k). And give a possible
solution.
4 An instance of the set cover problem consists of a set X of n elements, a family F of PO2,PO4 L2,L5
subsets of X, and an integer k. The question is, does there exist k subsets from F
whose union is X? For example, if X = {1, 2, 3, 4} and F = {{1, 2}, {2, 3}, {4}, {2,
4}}, there does not exist a solution for k = 2, but there does for k = 3 (for example,
{1, 2}, {2, 3}, {4}). Prove that set cover is NP-hard with a reduction from vertex
cover.
5 Suppose, the 3-SAT problem has k clauses, then it is satisfiable if and only if the PO2,PO4 L2,L5
corresponding graph has an independent set of size k. Now, give an example to show that 3-
SAT is not satisfiable if and only if the corresponding graph does not have any independent
set of size k.
6 Draw a graph 𝐺(𝑉, 𝐸) from the given information where V is the set of all vertices, 𝐸 = PO2,PO4 L2,L5
{(𝑣1 , 𝑣2 ), (𝑣1 , 𝑣9 ), (𝑣2 , 𝑣3 ), (𝑣2 , 𝑣8 ), (𝑣3 , 𝑣5 ), (𝑣4 , 𝑣5 ), (𝑣5 , 𝑣6 ), (𝑣6 , 𝑣7 ), (𝑣7 , 𝑣8 ), (𝑣7 , 𝑣9 )}
set of all edges.
Dept. of Comp. Sc. and Engg., ITER, S'O'A Deemed To Be University
a. Can a Vertex Cover of size 3 possible for the given graph? Justify your answer.
b. Can a Vertex Cover of size 4 possible for the given graph? Justify your answer.
c. Why can't an undirected Complete Graph with 8 vertices have a vertex cover of
size 3?
10. Given an approximation algorithm for weighted-vertex-cover problem as below: PO2,PO3, L2,L4
PO4
Vertex-Cover-Approx( G, w ) {
Set 𝑝𝑒 = 0 for all 𝑒 ∈ 𝐸
Dept. of Comp. Sc. and Engg., ITER, S'O'A Deemed To Be University
While (there is an edge 𝑒 = (𝑖, 𝑗) such that neither i nor j is tight) {
a. Using the above algorithm based on pricing method, find the weighted-vertex-cover
for the given graph with four vertices having vertex weights/costs 6, 5, 7 and 5.
Compare your solution with the optimal solution for this example.
b. Prove that: “For any vertex cover S, and any nonnegative and fair prices 𝑝𝑒 , we
have ∑𝑒∈𝐸 𝑝𝑒 ≤ 𝑊(𝑆) ” (Fairness lemma).
c. Show that “the set S returned by the above algorithm is a vertex cover, and its cost
is at most twice the minimum cost of any vertex cover.”
11. Find whether the given configuration S is stable or not. If not, then make it stable by using PO2,PO3, L2,L4
the state-flipping algorithm. An undirected weighted graph defines the configuration S PO4
consists of a set of nodes V={a, b, c, d, e, f}, set of edges E={(a, b), (a, e), (a, f), (b, f), (b,
c), (c, d), (e, d), (f, d)}, associated edge weights W={-1, 4, 6, -5, 1, 2, -3, 9}, and the node
assignment 𝑆𝑒 = 𝑆𝑓 = 𝑆𝑐 = −1 for all other nodes it is +1.
12. Can there be bad edges in a stable configuration S of a Hopfield neural network? Justify with PO2,PO3, L5
an example. An edge 𝑒 = (𝑢, 𝑣) is a bad edge, if 𝑤𝑒 𝑆𝑢 𝑆𝑣 > 0 , where 𝑤𝑒 is the weight of PO4
edge e, and 𝑆𝑢 = ±1 is the node assignment for a node u.
13. In a Hopfield neural network, for a given configuration S, An edge 𝑒 = (𝑢, 𝑣) having weight PO2,PO3, L4,L5
𝑤𝑒 < 0 then node u and v are in the same state represented by su=1 and sv=1 (or su=-1 and PO4
sv=-1). However, in general, a configuration may not respect the constraints. Justify with an
example.
14. Apply gradient descent local search algorithm to find the vertex cover from the given PO2,PO3, L5
complete bipartite graph G=(V, E), where V=L∪R, L={a, b, c, d, e}, and R={m, n, o, p, q, PO4
r}. Here complete bipartite graph means every vertices of L connected to the each and every
vertices of R. Can gradient descent always guarantee finding the global optimum from a
solution space? If not, why?
15. Apply gradient descent local search algorithm to find the vertex cover from the given graph PO2,PO3, L4
G=(V, E), where V={a, b, c, d} and E={(a,b),(c,d),(a,c),(b,d),(b,c)}. Find all possible local PO4
solutions. Can gradient descent always guarantee finding the global optimum from a solution
space? If not, why?
16. Select(S, k) PO2,PO3, L2,L4
{Choose a splitter 𝑎𝑖 ∈ 𝑆. PO4
for each element 𝑎𝑗 of S {
if aj < ai then put aj in S−
if aj > ai then put aj in S+
}
Dept. of Comp. Sc. and Engg., ITER, S'O'A Deemed To Be University
if |S−| = k − 1 then
return ai // the splitter ai was in fact the desired answer
else if |S−| ≥ k then
Select(S-,k) // the kth largest element lies in S−
else // suppose |S−| = t < k −1
Select(S+, k) // the kth largest element lies in S+
a. “Regardless of how the splitter is chosen, the algorithm Select(S,k) above returns
the kth largest element of S.” – TRUE/FALSE. Justify your answer.
b. If we could always choose the median as the splitter, then we could show a linear
bound on the running time. Let cn be the running time for Select(), not counting the
time for the recursive call. Then, with medians as splitters, give an upper bound on
the running time T(n).
17. Let U be a universal set. Each element 𝑥 ∈ 𝑈 is type of r-vector i.e 𝑥 = (𝑥1 , 𝑥2 , … . , 𝑥𝑟 ), PO2,PO3, L2,L4
where 0 ≤ 𝑥𝑖 < 𝑝. Let A= {set of all r-digits, p-base integers}. For 𝑎 = (𝑎1 , 𝑎2 , … . , 𝑎𝑟 ) ∈ PO4
𝐴, where 0 ≤ 𝑎𝑖 < 𝑝, define a hash function
ℎ𝑎 (𝑥): 𝑈 → {0,1, … . , 𝑝 − 1} such that ℎ𝑎 (𝑥) = (∑𝑟𝑖=1 𝑎𝑖 𝑥𝑖 )𝑚𝑜𝑑 𝑝. Then, a class 𝐇 of
hash functions is called universal if 𝑃𝑟ℎ∈H [ℎ(𝑥) = ℎ(𝑦)] ≤ 1⁄𝑝.
a. Compute the hash value of the elements x= (2, 3), y=(4, 5), z=(2,1) using the
above hash function. Where 𝐴 = {𝑎1 , 𝑎2 } , r=2 and 𝑎1 = (3,5), 𝑎2 = (1,3).
b. Find whether the 𝐇 = {ℎ1 , ℎ2 } is a universal family of hash functions or not.