Algo A5
Algo A5
Question # 1 20 Points
Question #2
APPROX-VERTEX-COVER(G)
C = ∅;
E’=G.E;
while(E’ ≠ ∅ ){
Randomly choose a edge (u,v) in E’, put u and v into C;
Remove all the edges that covered by u or v from E’
}
Return C;
Question 3 10 Points
An Instance (𝑋, 𝐹) of the set-covering problem consists of a finite set X and a family F of subset
of X, such that every element of X belongs to at least one subset of F:
𝑋 = ⋃𝑆
𝑆∈𝐹
We say that a subset 𝑆 ∈ 𝐹 covers all elements in X. Our goal is to find a minimum size subset
𝐶 ⊆ 𝐹 whose members cover all of X.
𝑋 = ⋃𝑆
𝑆∈𝐶
CS302
Consider each of the following words as a set of letters: {arid, dash, drain, heard, lost, nose, shun,
slate, snare, thread}. Show which set cover GREEDY-SET-COVER produces, when we break ties
in favor of the word that appears first in the dictionary.
Question 4: 20 Points
BEST OF LUCK
CS302
National University of Computer & Emerging Sciences, Karachi
Fall-2020 Department of Computer Science
Assignment 5
Due: 25th December 2020
Question # 1 20 Points
P problems
a. (The original definition) Problems that can be solved by deterministic Turing machine
in polynomial-time.
b. (A equivalent definition) Problems that are solvable in polynomial time.
NP problems
P = NP means whether an NP problem can belong to class P problem. In other words, whether
every problem whose solution can be verified by a computer in polynomial time can also be solved
by a computer in polynomial tim
CS302
(d) A problem that is solvable in time complexity of 𝑇(𝑛) = 3 ∗ 𝑛𝑛 and space complexity of 𝑆(𝑛) =
𝑛2 and it can be validated in 𝑇(𝑛) = 2𝑛 time. Is it a NP-Complete or NP-Hard? Explain
Sol: NP-Hard as validated in 𝑇(𝑛) = 2𝑛 time.
Question #2
APPROX-VERTEX-COVER(G)
C = ∅;
E’=G.E;
while(E’ ≠ ∅ ){
Randomly choose a edge (u,v) in E’, put u and v into C;
Remove all the edges that covered by u or v from E’
}
Return C;
Question 3 10 Points
An Instance (𝑋, 𝐹) of the set-covering problem consists of a finite set X and a family F of subset
of X, such that every element of X belongs to at least one subset of F:
𝑋 = ⋃𝑆
𝑆∈𝐹
We say that a subset 𝑆 ∈ 𝐹 covers all elements in X. Our goal is to find a minimum size subset
𝐶 ⊆ 𝐹 whose members cover all of X.
CS302
𝑋 = ⋃𝑆
𝑆∈𝐶
Consider each of the following words as a set of letters: {arid, dash, drain, heard, lost, nose, shun,
slate, snare, thread}. Show which set cover GREEDY-SET-COVER produces, when we break ties
in favor of the word that appears first in the dictionary
Question 4: 20 Points
A) Jarvis March: The points at the hull of convex in ordered form are: (−6, −10) →
(6, −6) → (8,0) → (9,5) → (−8,8) → (−10,4) → (−10,3) → (−8, −6).
B) Graham Scan: The points are as same as the Jarvis March but the deleted points are:
(6,2) → (6,4) → (−2,2) → (−4, −4) → (−3,4). The sorted points are: (−6, −10) →
(6, −6) → (8,0) → (9,5) → (6,2) → (6,4) → (−2,2) → (−4, −4) → (−3,4) →
(−8,8) → (−10,4) → (−10,3) → (−8, −6).
CS302
CS302