0% found this document useful (0 votes)
81 views4 pages

Assignment 2

This document outlines Assignment 2 for the CSE 4131: Algorithm Design 2 course at ITER, S'O'A Deemed To Be University, with a submission deadline of May 20, 2025. It includes various questions related to algorithm design concepts such as NP-Completeness, decision problems, set cover, and approximation algorithms, requiring detailed explanations and proofs. The assignment emphasizes clarity, neatness, and originality, with a total score of 100 points.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
81 views4 pages

Assignment 2

This document outlines Assignment 2 for the CSE 4131: Algorithm Design 2 course at ITER, S'O'A Deemed To Be University, with a submission deadline of May 20, 2025. It includes various questions related to algorithm design concepts such as NP-Completeness, decision problems, set cover, and approximation algorithms, requiring detailed explanations and proofs. The assignment emphasizes clarity, neatness, and originality, with a total score of 100 points.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Dept. of Comp. Sc. and Engg.

, ITER, S'O'A Deemed To Be University

CSE 4131: ALGORITHM DESIGN 2


Assignment 2:
Submission due date: 20/05/2025
 Assignment scores/markings depend on neatness and clarity.
 Write your answers with enough detail about your approach and concepts used, so that the grader will be able to
understand it easily. You should ALWAYS prove the correctness of your algorithms either directly or by referring to
a proof in the book.
 The marking would be out of 100
 You are allowed to use only those concepts which are covered in the lecture class till date.
 Plagiarized assignments will be given a zero mark.

Assignment questions based on CO2, CO3, CO4, CO5, CO6


Sl. Questions PO level
No.
1 a. Define the class NPC (NP-Complete). What are the defining properties of an NP- PO2,PO4 L1, L2
Complete problem?
b. Provide examples of well-known NP-Complete problems and explain why they are
considered as such.
c. Explain the concept of polynomial-time reduction. How is it used to prove a problem
is NP-Complete?
2 a. Write the 3-SAT expression for the given QSAT expression PO2,PO4 L5
“∃𝑥1∀𝑥2∃𝑥3∀𝑥4∃𝑥5 𝜑(𝑥) = (𝑥1 ∨ ¬𝑥3 ∨ 𝑥4) ∧ (¬𝑥2 ∨ 𝑥3 ∨ ¬𝑥5) ∧ (¬𝑥1 ∨
𝑥3 ∨ ¬𝑥2)” using appropriate quantifiers.
b. Is there a satisfying assignment for the given Q-SAT “∃𝑥1∀𝑥2∃𝑥3 𝜑(𝑥) = (𝑥1 ∨
¬𝑥3 ∨ 𝑥2) ∧ (¬𝑥2 ∨ 𝑥3 ∨ ¬𝑥1) ∧ (¬𝑥1 ∨ ¬𝑥3 ∨ ¬𝑥2).
c. Why Q-SAT ∈ PSPACE?

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?

7. Greedy-Balance (n, m, t[1...n]) { PO2, L2, L5


PO3,
Start with no jobs assigned
PO4
Set Ti = 0 and 𝐴𝑖 = ∅ for all machines 𝑀𝑖
For j = 1, . . . , n do {
Let 𝑀𝑖 be a machine that achieves the minimum min 𝑇𝑘
𝑘

Assign job j to machine 𝑀𝑖


Set 𝐴𝑖 ← 𝐴𝑖 ∪ { 𝑗}
Set 𝑇𝑖 ← 𝑇𝑖 + 𝑡𝑗
}
return 𝐴[1], 𝐴[2], … , 𝐴[𝑚]
}
a. Show that algorithm Greedy-Balance produces an assignment of jobs to machines
with makespan 𝑇 ≤ 2𝑇 ∗.
b. What will be the resulting makespan of running this greedy algorithm on a sequence
of six jobs with processing times 12, 13, 14, 16, 12, 12 for m=3 identical machines?
8. Consider an example scenario of Center-Selection problem with only two sites s and z, and PO2,PO3, L4
k = 2. Assume that s and z are located in the plane, with distance equal to the standard PO4
Euclidean distance in the plane, and that any point in the plane is an option for placing a
center. Let d be the distance between s and z. Then find the best location for (i) Case1: a
single center c1 and (ii) Case2: then subsequent best location for second center c2. In each
case, also find the optimal covering radius r(C).
9. Given an approximation algorithm for weighted-set-cover problem as below: PO2,PO3, L5
Greedy-Set-Cover() { PO4
Start with R = U and no sets selected
while (R ≠ Ф )
Select set Si that minimizes 𝑤𝑖 /|𝑆𝑖 ∩ R|
𝑆 = 𝑆 ∪ {𝑆𝑖 }
Delete set 𝑆𝑖 from R. // 𝑅 = 𝑅 − {𝑆𝑖 }
}
Return the selected sets S
}
Using the above algorithm, find the solution S for the following set-cover problem instance
and compare this solution with the optimal solution S*. Set-Cover instance with
U={1,2,3,4,5,6,7,8}, and list of subsets such as S1={1,3,5,7}, S2={2,4,6,8}, S3={1},
S4={2}, S5={3,4}, S6={5,6,7,8} and weight array w[] = {1+ε, 1+ε, 1,1,1,1}, where ε is a
very small value between 0 and 1.

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) {

Select such an edge 𝑒


Increase 𝑝𝑒 without violating fairness
}
Let S be the set of all tight nodes
Return S
}

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.

You might also like