DAA Unit - V
DAA Unit - V
DAA Unit - V
/can the list of vertices obtained in step ' and eli"inate fro" it all repeated
occ(rrences of the sa"e verte+ e+cept the startin# one at the end of list$ The
vertices re"ainin# in the list for" the 3a"iltonian circ(it$
3<. Pro=e t2at t2e t7i.e1aroun-1t2e1tree algorit2m i5 a ,1appro@imation algorit2m
)or t2e tra=eling 5ale5man pro/lem 7it2 Eu.li-ean -i5tan.e5.
Twice)aro(nd)the)tree al#orith" is a polyno"ial al#orith", as we (se the !ri"0s or
1r(s,al0s al#orith" to #enerate a "ini"(" spannin# tree$ As the len#th of the to(r /a
obtained by the twice)aro(nd)the)tree al#orith" is at "ost twice the len#th of the opti"al
to(r /8E that is f(sa 56 'f(s8
Je"ovin# any ed#e fro" /8 yields a spannin# tree T of wei#ht w(T, which "(st be #reater
than or e@(al to the wei#ht of the #raph0s "ini"(" spannin# tree w(T8$ Now the ine@(ality
is2 f(s8 < w(T <6 w(T8 K 'f(s8 < 'w(T8$
Co"binin# the last two ine@(alities, we #et the ine@(ality 'f(s8 < f(sa$
Th(s the twice)aro(nd)the)tree al#orith" is a ')appro+i"ation al#orith" for the travelin#
sales"an proble" with E(clidean distances$
3>. Pro=e t2at i) P not eFual to P, t2en t2ere e@i5t5 no .1appro@imation algorit2m
)or t2e tra=eling 5ale5man pro/lem.
That is, there e+ists no polyno"ial)ti"e al#orith" for this proble" so that for all
instances f(sa 56 cf(s8 $ /(ppose that s(ch an appro+i"ation al#orith" A and a constant
C e+ists, to prove this by contradiction$ %et I be an arbitrary #raph with n vertices$ BE "ap
I to a co"plete wei#hted #raph I0 by assi#nin# wei#ht & to each of its ed#es and addin# an
ed#e wei#hted cnL& between each pair of vertices not ad?acent in I$
If I has a 3a"iltonian circ(it its len#th in I0 is n$ f(sa$ 56 cn$
If I does not have a 3a"iltonian circ(it, the shortest to(r in I0 will contain at least
one ed#e of wei#ht cnL&$ f(sa <6 f(s8 <cn$
Ta,in# both the ine@(alities, we can solve the 3a"iltonian circ(it proble" with
polyno"ial al#orith", while "appin# I to I0 and applyin# al#orith" A to #et the shortest
Prepared By
Mrs.A.Subathra Devi AP / MCA
6
to(r in I0, which is also based on constant c$ This is a contradiction to !6N!$ 3ence the
assertion is ri#ht$
3B. ?2at i5 a )ir5t1)it algorit2m an- a )ir5t1)it -e.rea5ing algorit2m )or /in
pa.3ing+
The first)fit al#orith" places each ite" in the order #iven, into the first bin the ite"
fits inE when there are no s(ch bins, place the ite" in a new bin and add this bin to the end
of bin list$
The fits)fit decreasin# al#orith" for the bin)pac,in# proble" starts by sortin# the
ite"s in non)decreasin# order of their si:es and then acts as the first)fit al#orith"$
Part 1 ;
(. E@plain P an- P pro/lem5 7it2 e@ample5. 8De. ,0(0, Aun ,0(( * ,0(,9
P 1 Pro/lem:
! vers(s N! polyno"ial vers(s nondeter"inistic polyno"ial refers to a theoretical
@(estion presented in &>M& by %eonid %evin and /tephen Coo,, concernin# "athe"atical
proble"s that are easy to solve ! type as opposed to proble"s that are diffic(lt to solve N!
type$
Any ! type proble" can be solved in Npolyno"ial ti"e$N A polyno"ial is a
"athe"atical e+pression consistin# of a s(" of ter"s, each ter" incl(din# a variable or
variables raised to a power and "(ltiplied by a coefficient$ A ! type proble" is a polyno"ial
in the n("ber of bits that it ta,es to describe the instance of the proble" at hand$ An
e+a"ple of a ! type proble" is findin# the way fro" point A to point B on a "ap$ An N!
type proble" re@(ires vastly "ore ti"e to solve than it ta,es to describe the proble"$ An
e+a"ple of an N! type proble" is brea,in# a &'O)bit di#ital cipher$ The ! vers(s N!
@(estion is i"portant in co""(nications, beca(se it "ay (lti"ately deter"ine the
effectiveness or ineffectiveness of di#ital encryption "ethods$
P 1 Pro/lem:
An N! proble" defies any br(te)force approach at sol(tion, beca(se findin# the
correct sol(tion wo(ld ta,e trillions of years or lon#er even if all the s(perco"p(ters in the
world were p(t to the tas,$ /o"e "athe"aticians believe that this obstacle can be
s(r"o(nted by b(ildin# a co"p(ter capable of tryin# every possible sol(tion to a proble"
Prepared By
Mrs.A.Subathra Devi AP / MCA
7
si"(ltaneo(sly$ This hypothesis is called ! e@(als N!$ 4thers believe that s(ch a co"p(ter
cannot be developed ! is not e@(al to N!$ If it t(rns o(t that ! e@(als N!, then it will beco"e
possible to crac, the ,ey to any di#ital cipher re#ardless of its co"ple+ity, th(s renderin# all
di#ital encryption "ethods worthless$
In co"p(tational co"ple+ity theory, N! is one of the "ost f(nda"ental co"ple+ity
classes$ The abbreviation N! refers to Nnondeter"inistic polyno"ial ti"e$N
The e@(ivalence of the two definitions follows fro" the fact that an al#orith" on s(ch
a non)deter"inistic "achine consists of two phases, the first of which consists of a #(ess
abo(t the sol(tion, which is #enerated in a non)deter"inistic way, while the second consists
of a deter"inistic al#orith" that verifies or re?ects the #(ess as a valid sol(tion to the
proble"$
The co"ple+ity class ! is contained in N!, b(t N! contains "any i"portant proble"s,
the hardest of which are called N!)co"plete proble"s, for which no polyno"ial)ti"e
al#orith"s are ,nown for solvin# the" altho(#h they can be verified in polyno"ial ti"e$ The
"ost i"portant open @(estion in co"ple+ity theory, the ! 6 N! proble", as,s whether
polyno"ial ti"e al#orith"s act(ally e+ist for N!)co"plete, and by corollary, all N! proble"s$
It is widely believed that this is not the case$
,. De5ign a pol0nomial time algorit2m )or a , .oloring pro/lem -etermine 72et2er
=erti.e5 o) a gi=en grap2 5an /e .olore- in no more t2an , .olor5. 8De. ,0(09
In #raph theory, #raph colorin# is a special case of #raph labelin#, it is an assi#n"ent
of labels traditionally called NcolorsN to ele"ents of a #raph s(b?ect to certain constraints$ In
its si"plest for", it is a way of colorin# the vertices of a #raph s(ch that no two ad?acent
vertices share the sa"e colorE this is called a verte+ colorin#$ /i"ilarly, an ed#e colorin#
assi#ns a color to each ed#e so that no two ad?acent ed#es share the sa"e color, and a face
colorin# of a planar #raph assi#ns a color to each face or re#ion so that no two faces that
share a bo(ndary have the sa"e color$
Perte+ colorin# is the startin# point of the s(b?ect, and other colorin# proble"s can
be transfor"ed into a verte+ version$ Aor e+a"ple, an ed#e colorin# of a #raph is ?(st a
verte+ colorin# of its line #raph, and a face colorin# of a plane #raph is ?(st a verte+ colorin#
of its d(al$ 3owever, non)verte+ colorin# proble"s are often stated and st(died as is$ That is
partly for perspective, and partly beca(se so"e proble"s are best st(died in non)verte+
for", as for instance is ed#e colorin#$
The convention of (sin# colors ori#inates fro" colorin# the co(ntries of a "ap, where
each face is literally colored$ This was #enerali:ed to colorin# the faces of a #raph e"bedded
in the plane$ By planar d(ality it beca"e colorin# the vertices, and in this for" it #enerali:es
to all #raphs$ In "athe"atical and co"p(ter representations, it is typical to (se the first few
positive or nonne#ative inte#ers as the NcolorsN$ In #eneral, one can (se any finite set as
the Ncolor setN$ The nat(re of the colorin# proble" depends on the n("ber of colors b(t not
on what they are$
Iraph colorin# en?oys "any practical applications as well as theoretical challen#es$
Beside the classical types of proble"s, different li"itations can also be set on the #raph, or
on the way a color is assi#ned, or even on the color itself$ It has even reached pop(larity
Prepared By
Mrs.A.Subathra Devi AP / MCA
8
with the #eneral p(blic in the for" of the pop(lar n("ber p(::le /(do,($ Iraph colorin# is
still a very active field of research$
Pol0nomial time:
Deter"inin# if a #raph can be colored with ' colors is e@(ivalent to deter"inin#
whether or not the #raph is bipartite, and th(s co"p(table in linear ti"e (sin# breadth)first
search$ Qore #enerally, the chro"atic n("ber and a correspondin# colorin# of perfect
#raphs can be co"p(ted in polyno"ial ti"e (sin# se"i definite pro#ra""in#$ Closed
for"(las for chro"atic polyno"ial are ,nown for "any classes of #raphs, s(ch as forest,
chordal #raphs, cycles, wheels, and ladders, so these can be eval(ated in polyno"ial ti"e$
If the #raph is planar and has low branch width, then it can be solved in polyno"ial
ti"e (sin# dyna"ic pro#ra""in#$ In #eneral, the ti"e re@(ired is polyno"ial in the #raph
si:e, b(t e+ponential in the branch width$
E@a.t algorit2m5:
Br(te)force search for a k)colorin# considers every of the assi#n"ents of k colors
to n vertices and chec,s for each if it is le#al$ To co"p(te the chro"atic n("ber and the
chro"atic polyno"ial, this proced(re is (sed for every , i"practical for
all b(t the s"allest inp(t #raphs$
Usin# dyna"ic pro#ra""in# and a bo(nd on the n("ber of "a+i"al independent
sets, k)colorability can be decided in ti"e and space $ Usin# the principle of
incl(sion-e+cl(sion and Rates0s al#orith" for the fast :eta transfor", k)colorability can be
decided in ti"e for any k$ Aaster al#orith"s are ,nown for S) and T)colorability,
which can be decided in ti"e and , respectively$
Running time: !(,
n
n)
3. Di5.u55 t2e appro@imation algorit2m P :ar- )or 5ol=ing Tra=elling &ale5man
pro/lem. Di=e e@ample. 8De. ,0(09
The travelin# sales"an proble" consists of a sales"an and a set of cities$ The
sales"an has to visit each one of the cities startin# fro" a certain one (e$#$ the ho"etown
and ret(rnin# to the sa"e city$ The challen#e of the proble" is that the travelin# sales"an
wants to "ini"i:e the total len#th of the trip$ The travelin# sales"an proble" can be
described as follows2
Prepared By
Mrs.A.Subathra Devi AP / MCA