assign6.docx
TRANSCRIPT
-
8/17/2019 assign6.docx
1/6
ASSIGNMENT 6
FOUNDATION OF ALGORITHMS
CHINMAY KULKARNI
(ck1166)
-
8/17/2019 assign6.docx
2/6
1. Given 2 graphs G1 and G2 !e need "# pr#ve "ha" $GraphIs#%#rphis%& '#r $ G1
G2& !hich checks !he"her "he 2 graphs are is#%#rphs #' each #"her is N pr#*e%+
,-pp#se "here is an a*g#ri"h% !hich veri.es "ha" G1 and G2 '#**#! is#%#rphis% #r
n#"+ I" can e d#ne / checking !he"her "he graph G1 and G2 are per%-"a"i#ns #'
each #"her+ I' /es "hen re"-rn "he '#**#!ing per%-"a"i#n and i' n# "hen graphs G 1
and G2 are n#" is#%#rphic+
0nce !e ge" "he per%-"a"i#n !e app*/ "ha" per%-"a"i#n "# #ne #' "he graph and
check !he"her "ha" graph is iden"ica* "# #"her graph+
# ge" "he per%-"a"i#n "he a*g#ri"h% re-ires 0(%2) !here % is n-%er #' ver"ices
and "# check !he"her "he per%-"a"i#n app*ied "# a graph genera"es an iden"ica*
graph "# #"her graph has 0(%3n) "i%e c#%p*e4i"/+
0vera** "he a*g#ri"h%s c#%p*e4i"/ is 0(%2) hence i" e*#ngs "# N+
2. pr#ve N ≠coNP, then P≠NP
We can follow a contrapositive way to prove this equation,
If P=NP then, NP≠coNP,
Suppose X ∈ NP, then X ∈ P and since P is closed under complement that’s why X’∈ P and
hence
X ∈ conP. (1)
For X ∈
coNP, X ' ∈
P and since P is closed under complement that’s why X ∈
P and therefore
X ∈ NP (2).
From (1) and (2),
We can say that NP=coNP.
-
8/17/2019 assign6.docx
3/6
3.
5hen !e c#nver" "his circ-i" "# ##*ean e4pressi#n !e ge"7
(89 ⋁ (81 ⋀ 82 ⋀ ¬ 89)) ⋀ (89 ⋀ (81 ⋁ 82)) ⋀ (81 ⋀ 82 ⋀
¬ 89)
And !e app*/ a** "he c#%ina"i#ns #' va*-es "# 81 82 89 !e a*!a/s ge" a va*-e #' :7
81 82 89 0-"p-"
: : : :
: : 1 :
: 1 : :
: 1 1 :
1 : : :
1 : 1 :
1 1 : :
1 1 1 :
Hence !e can sa/ "ha" i" is -nsa"is.a*e+
-
8/17/2019 assign6.docx
4/6
4. A ;is
-
8/17/2019 assign6.docx
5/6
5e need "# pr#ve "his 'ac"
$A"& ∈ s-se" s-% and AF ∈ ARII0N !here s-% #' n-%ers in AF (2pD2")
I' "here e4is"s a s-se" A in , !h#se s-% is " "hen hence "he re%aining n-%ers in
, !i** have s-%
(p D ") "here'#re "here is par"i"i#n in AF s-ch "ha" #"h have s-% as (pD")+
And n#! i' "here is par"i"i#n in AF s-ch "ha" #"h c#n"ain s-% pD" "hen #ne #' "he
par"i"i#n !i** c#n"ain pD2" and re%#ving "his give -s "he se" #' n-%ers !h# have
s-% as "+
Hence !e have red-ced ,-se" s-% pr#*e% "# ar"i"i#n pr#*e% and as !e kn#!
"ha" ,-se" s-% is N c#%p*e"e "here'#re !e can sa/ "ha" ARII0N I, N
c#%p*e"e+
6. a. pse-d#c#de '#r rec-rsive :D1 knapsack pr#*e%
de' knapsacker#0neRec-rsive ("arge"5" a*-es 5eigh"s n)7
"arge"5"he "arge" !eigh" "# e achived !i"h %a4i%-%
c#rresp#nding va*-es
a*-es va*-es ass#cia"ed !i"h n i"e%s
5eigh"s !eigh"s ass#cia"ed !i"h va*-es in n+
i' n: #r "arge"5":7 ase case+ re"-rn :
i' !eigh"nD1O& "arge"5"7 "his %eans "ha" "arge" !eigh" "#
achieve is *ess "han "he
c-rren" !eigh" in "he !eigh" arra/+ hen !e !i** search '#r #"her
!eigh"s in arra/
Re"-rn knapsacker#0neRec-rsive ("arge"5" a*-es 5eigh"s nD
1)
E*se7 re"-rn "he %a4 va*-e e"!een i' n"h !eigh" is inc*-ded #r i' i" is
n#" inc*-ded+
Re"-rn %a4(va*-esnD1O3 knapsacker#0neRec-rsive ("arge"5"D
5eigh"snD1O a*-es 5eigh"s nD1) ) knapsacker#0neRec-rsive ("arge"5" a*-es
5eigh"s nD1))
-
8/17/2019 assign6.docx
6/6
6.c. he c#%p*e4i"/ #' d/na%ic pr#gra%%ing a*g#ri"h% '#r :D1 knapsack pr#*e% is
0(n("arge"5)) !here n is n-%er #' ch#ices #' !eigh"s and va*-es+
6.d. N0 ≠NP, because we cannot generalize solution of 1 NP complete solution to all the NP
problems.
Because, there are large number of NP Problems of different kinds ,we can reduce all Np Problems to
Np complete problems . The NP complete problems can be verified in polynomial time but cannot be
solved in polynomial time.