• Keine Ergebnisse gefunden

Discrete Mathematics 3. Exercise Sheet

N/A
N/A
Protected

Academic year: 2022

Aktie "Discrete Mathematics 3. Exercise Sheet"

Copied!
5
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Algorithmic

Discrete Mathematics 3. Exercise Sheet

Department of Mathematics SS 2012

PD Dr. Ulf Lorenz 23. and 24. May 2012

Dipl.-Math. David Meffert Version of July 15, 2012

Groupwork

Exercise G1

Let the algorithm CLIQUE be defined by:

input : A graphGand a natural numberk.

output : ’yes’, ifG contains a clique of cardinalityk. Otherwise ’no’.

Let the algorithm IDEPENDENT SET (IS) be defined by:

input : A graphGand a natural numberk.

output : ’yes’, ifG contains an independent set consisting ofkvertices. Otherwise ’no’.

Show that CLIQUE≤P IS.

Solution: First lets determine the polynomial function f which transforms the inputsG= (V,E)andk∈Nof CLIQUE to suitable inputs for IS. It is given by f(〈G,k〉) =〈G0,k〉withG0 = (V,E0). The set E0 is defined by(v,w)E0 ⇐⇒

(v,w)6∈E.G0is called the complementary graph (see H8).

claim: Gcontains a clique of cardinalityk ⇐⇒ G0contains an independent set of cardinalityk.

proof:

• ⇒Letv1, . . . ,vk be a clique of cardinalityk. Hence for every two different verticesvi fori∈ {1, . . . ,k}they are directly connected by an edge. By definition this means they are not directly connected by an edge inG0. So the verticesv1, . . . ,vk form an idenpendent set inG0.

• ⇐ Assume that G contains no clique of cardinality k. Take an arbitary subset SV consisting of k elements v1, . . . ,vk. Because by assumption it is not a clique ofGthere existi,j∈ {1, . . . ,k}withi6= jand(vi,vj)6∈E. By definition this means(vi,vj)∈E0and for this reasonS=v1, . . . ,vkcan’t form an independent set inG0. BecauseS was chosen arbitrarily the second implication is proven.

Exercise G2 (Bipartite graphs)

Prove that a graph(V,E)is bipartite iff it contains no cycles of odd length.

Solution:

• ⇒LetGbe bipartite with induced partionV =S∪˙T. Let(v1,v2, . . .vn,v1)be a cycle inG and w.l.o.g. letv1S.

Since there are no edges inside the setsSandT, we getv2kTandv2k+1Sfork∈ {1, . . .bn2c}. So it is necessary thatnis even forvnbeing an element ofT. Hence there are no cycles of odd length.

• ⇐LetG be a graph without odd cycles. Without loss of generality we ca assume thatG is connected. Otherwise do the same argumentation for each connected component of the graph. For a verticex0V letSbe the set of all vertices inVwith even distance1to the vertexx0. Additionally we call its complementT:=V\S. We want to show that there are no edges withinSandT. So assume there is an edge(x,y)∈E, such thatx,yS. LetWxandWy be shortest paths fromx0toxand to yrespectively. By definition ofSthe pathsWxandWyboth have even length.

Now letzbe the last common vertice of the pathsWxandWy(both beginning inx0) and denote byWx0andWy0the remaining part of the paths fromztoxandyrespectively. Now define the cyclexWx0zWy0y−(x,y)→x.

SinceWx0 andWy0 both have either odd or even length the given cycle has odd length. This contradicts Ghaving

1 The distance of two verticesx,yin a graphGis defined as the number of edges used in a shortest path fromxtoy.

(2)

no cycles of odd length, hence our assumption was wrong and for this reason there are no edges in the setS. The statement for the setT can be shown the same way. So we haveV =S∪˙T with suitable setsV andT. Hence the graphGis bipartite.

Exercise G3 (Eulerian graphs)

A path in a GraphG= (V,E)is calledEulerian path, if it contains every edgeeEexactly once. An Eulerian path which is a cycle is calledEulerian cycle. A graph is calledeulerianif it contains an Eulerian cycle.

(a) Which of the given graphs inFigure 1are Eulerian graphs?

Figure 1:Eulerian graphs?

(b) Now letGbe a connected graph. Name necessary conditions forGbeing eulerian.

(c) Are these conditions sufficient, too?

Solution:

(a) The solution is yes,no,yes,no. The best way to prove the nonexistence of an Eulerian cycle is by using one of the criterias of part(b).

(b) We look at the following two conditions and prove that they are necessary. Later we will show they are even equivalent.

i. Ecan be decomposed into cycles having disjoint edges.

ii. All vertices inV have an even degree.

Lets prove necessity of the conditions. So letG= (V,E)be a graph andT= [e1, . . . ,en]be an Eulerian cycle inG.

We prove the decomposition into cycles first. So we take an arbitrary verticevV and follow the path given by T till we reach the vertexv again. If the cycleCconstructed that way is the whole Eulerian cycle we are finished.

Otherwise delete all the edges ofC in the set E and delete all vertices inV which got isolated by this deletion process. The resulting graphV0= (G0,E0)is eulerian again. So we repeat this procedure till the resulting graph is empty. By construction we get a decomposition of cycles having disjoint edges.

Now we can conclude the second condition (all vertices have even degree). LetvV arbitrary. By doing the same procedure as for the cycle decomposition and always choosingv as the starting node we get exactly2new incident edges ofv in every step tillv becomes an isolated node. By construction they are all disjoint, henced(v) =2kv withkv is the number of disjoint cycles containingv. SincevV was arbitrarily chosen we are done.

(c) Yes the given conditions in part(b)are also sufficient. We we will prove this the following way. First we prove that a graph can be decomposed into cycles with disjoint edges, iff all vertices have even degree. After that we just have to prove the first condition.

So lets start with the equivalence. The first implication was already shown in part(b). So letGbe a graph where all vertices have even degree. We use induction over the number of edgeskinGto prove the decomposition.

Base case:Fork=0the graph is trivially decomposed into cycles with disjoint edges.

Induction hypothesis:Assume that every graph with at mostkedges can be decomposed into cycles with disjoint

(3)

edges.

Inductive step: LetG be a graph withk+1edges,vV an arbitrary vertex andv1V with(v,v1)∈E. Since d(v1)≥2there exists a vertexv26=v with(v1,v2)∈E. By iterating this process, becauseGis a finite graph, we will come to a vertexvl we already visited. So we get a cycle C= [vl,vl+1, . . . ,vl]in G. IfCcontains all edges in E we are done. Else we delete all these edges contained in the cycle and all vertice getting isolated by this deletion process (those with d(v) =2). The resulting graphG0 = (V0,E0)contains less thank edges and by the induction hypothesis can be decomposed to a decompositionE of cycles with disjoint edges. The setE ∪ {C}yields a decomposition of cycles with disjoint edges for the whole graphG.

Now we construct an Eulerian cycle out of the cycle decomposition with disjoint edges. Again we use induction over the numbermof disjoint cycles.

Base case:Form=1the only cycle we have is of course an Eulerian cycle.

Induction hypothesis:Assume that every connected graph that can be decomposed into at mostmdisjoint cycles has an Eulerian cycle.

Inductive step:LetE be a decomposition intom+1disjoint cycles. Choose a cycleC∈ E and delete all edges in CfromEand all vertices getting isolated by the deletion process. Since all connected components of the resulting graphG0= (V0,E0)have a decomposition into at mostmdisjoint cycles, they all have an Eulerian cycle by using the induction hypothesis. With these cycles we construct an Eulerian cycle forGthe following way. Start with an arbitrary vertexvC and follow the cycle till the first nodev1V0. Now follow the Eulerian cycle induced by connected component(V1,K1)containingv1. Now keep on following the cycleCtill the first nodev1V0\{V1}.We repeat this procedure till we went through the whole cycleC and get to the starting vertexv again.(after going through all the Eulerian cycles of the connected components) Since the graphGis connnected we went through all the Eulerian cycles which are induced by the connected components ofG0and the cycleCand for this reason have contructed an Eulerian cycle forG.

Exercise G4 (Primes and the classN P)

The class of problems whose complement is inN P is called co-N P. For the following exercise assume that the coding length of a natural numbernis given by〈n〉=blog2nc+1.2

(a) Show that the problem PRIMES, to determine if a given natural number is prime, is a co-N P problem.

(b) Why would it be much harder to show that this problem is also in the classN P? (c) Prove PRIMES∈ N P under the assumption〈n〉=n.

Solution:

(a) We have to prove that the problem to determine if a given numberpis not a prime, is anN P-problem.

A suitable object (certificate) forpnot being a prime are two natural numbera,bwith1<a<b<pwitha·b=p.

With this object one can easily check if the given answer ’yes’ (p is not a prime) was correct. The algorithm to do this gets the inputs pand(a,b)and decides if(a,b)is a suitable certificate forp by checking ifa·b= pand 1<a<b<p. Because ofa,b<pthe binary representation ofa,bis shorter than the one ofp. So the runtimel for the mutiplication ofaandbismax{〈a〉 〈b〉} ·1≤ 〈p〉. The runtime for the comparing of the numbersa·band pis〈p〉. Same holds for checking1<a<b<p. So the algorithm is linear inp〉, so in particular polynomial〈p〉. (b) This is much harder because one would need a certificate (probably a number or a set of numbers) which can be

used (in polynomial time) to prove thatpis prime. The coding length should also be polynomial in〈p〉. It is not clear how such a certificate should look like. The set of all numbers smaller thanpis not a good choice because the coding length of this set is equal toPp−1

i=1(blog2ic+1)which is not polynomial in〈p〉=blog2pc+1.

Indeed such certificates do exist. The first one was found in1975by the australian mathematician Vaughan Pratt (born 1944). It consists of a number xwhich is coprime topand has some other properties.

(c) Under this assumption a polynomial algorithm with a polynomial certificate is for example given by all natural numbers smaller thanp(orpp) and checking if the division yields a natural number or not. Under the assumption

p〉=pthis certifate has polynomial coding length and the checking algorithm usespdivisions and for this reason has a runtime ofp· 〈p〉=p2which is of course polynomial in〈p〉=p.

In fact solving this problem is also possible with the usual coding length (binary representation), but is was a open question for quite a long time. An algorithm was found in2002by the Indian mathematicians Manindra Agrawel, Neeraj Kayal and Nitin Saxena.

2 This is the common binary representation of a natural numbern. Hence you needblog2nc+1digits.

(4)

Homework

Exercise H7 (Trees) (10 points)

LetG= (V,E)be a graph withn≥2vertices. Proof that the following statements are equivalent:

(a) Gis a tree.

(b) Gis connected and containsn−1edges.

(c) Gcontainsn−1edges but no cycles.

(d) Gis minimally connected. That means for every edgeeEthe graphG\ {e}= (V,E\ {e}) is not connected.

(e) Gcontains no cycles and adding one edge generates exactly one cycle.

(f) For every two nodesu,vV there is exactly one[u,v]-path inG.

Solution: There are several ways to prove the equivalences by proving different implications. We present one way to it.

(a)⇒(b)and(c): We prove this by induction over the number of verticesn. Forn=1we have only one vertex and no edges (otherwise there would be a cycle). So the graph hasn−1=0edges and is of course connected and has no cycles. Now assume the statement we want to prove is right for all trees with a mostnvertices. LetG be a tree with n+1vertices. Sincen+1>1it is not hard to see, that we have at least one leafv in the graphG. (by looking a simple path of maximal length in the tree) Delete this vertexv and its one incident edge. Sincev was a leaf the resulting graph G0= (V0,E0)is still connnected and has no cycles becauseGhad not cycles in advance.(soG0is a tree withnvertices) By assumptionG0hasn−2edges is connected and has no cycles. Adding the deleted leaf with its edge to graph again (to get backG) we seeT hasn−1edges, is connected and has no cycles.

(a)⇒(d): Lete= (u,v)be an arbitrary edge inG. AssumeG\ {e}is connected. Then there exists a path fromutov which does not use the edgee. By addingeto this path we get a cycle which contradictsGbeing a tree.

(a)⇒(f): Letu,vV. SinceG is connected there is a least one pathp= (v=v1, . . . ,vk=u)inG. Assume there is another pathq= (v=q1, . . . ,ql=u). Letibe the smalllest index withvi6=qiand jthe smallest withvj=qjand j>i.

Notice we havei>1(v1=q1) and jexists sincevk=ql. Taking the pathc= (vi−1,vi, . . . ,vj=qj,qj−1, . . .wi−1=vi−1) we get a cycle which is a contradiction toGbeing a tree.

(a)⇒(e): Assume we want to add the edgee= (v,u)forv,uV. BecauseGwas already connected there is a path fromutov not usinge. Be adding the edgeeto this path we get a cycle. Since the path fromutov was unique be part (f)this is the only cycle we get by addinge.

(b)⇒(a): Assume we have a cycleCin the graphG. If we delete an arbitrary edgeeCthe graph is still connected.

This way we can remove all the cycles fromGan get a connected graph G0without cycles. SoG0 is a tree and for this reason has to haven−1edges. This is a contradiction toGalready havingn−1edges, because we deleted at least one edge. SoGalready had no cycles.

(c)⇒(a): AssumeGis not connected and consists of the connected componentsK1, . . . ,Kr. Then we can connect an arbitrary vertexv1K1with another verticev2K2without generating a cycle. We do the same thing for all the other connected components and get a graphG0which is a connected and without cycles, hence a tree. SoG0hasn−1edges which is a contradiction toGalready havingn−1edges, because we at least added one edge.

(d)⇒(a): We have to show that G has no cycles. Assume there is a cycleC inG. Then we can delete an arbitrary edgeeCand the resulting graphG0is still connected. This contradictsG being minimally connected.

(e)⇒(a): We have to prove thatGis connected. Assume it is not. Then there at least two connected componentsK1 andK2ofGand we can add an arbitrary edge between any verticesv1K1andv2K2without getting a cycle. This is a contradiction.

(f)⇒(a): Since there is path fromutov for arbitrary verticesu,vV the graphGis connected. IfGwould contain any cycleCthere would be at least two different paths fromutov for arbitrary verticesu,vC. SoGcontains no cycles.

Exercise H8 (The complement graph) (10 points)

The complement graphG of G = (V,E)is the graph were two vertices are adjacent iff they are not adjacent inG. So formally speaking we haveG:= (V, [n2]

\E)with [n]

2

\E:={(i,j)|i6=j∈ {1, . . . ,n}(i,j)/E}. LetGbe an undirected graph. Prove thatGorGis connected.

(5)

Solution: Lets assume G is not connected. (otherwise we are done). Without loss of generality one can assume that G has exactly two connected componentsK1andK2. The general case can be proved by induction over the number of components.

LetV1consist of the vertices ofK1andV2of the vertices ofK2. In the worst caseG is a complete bipartite graph with partitionsV1andV2. ForvV1andwV2the edge(v,w)is a[v,w]-path inG. Letv,wV1. Taking an arbitraryuV2 the path(v,u,w)is a[v,w]-path. Forv,wV2it works the same way. SoGis connected.

Exercise H9 (10 points)

Prove SUBSETSUM≤pPARTITION.

problem : SUBSETSUM input :a1, ...,an,b∈N output :T⊆ {1, ...,n}withP

kTak=b problem : PARTITION

input :a1, ...,al∈N

output :T⊆ {1, ...,l}withP

k∈Tak=P

k/∈Tak

Solution: First lets determine the polynomial function f which transforms the inputs a1, . . . ,an ∈N and b ∈N of SUBSETSUM to suitable inputs for PARTITION. It is given by f(〈a1, . . . ,an,b〉) =〈a1, . . . ,an,an+1,an+2〉with an+1 = Mb+1andan+2=b+1. The numberMis defined byM:=Pn

k=1ak. This transformation can be done in polynomial time.

claim: T⊆ {1, . . . ,n}is a solution for SUBSETSUM with inputsa1, . . . ,an,b∈N ⇐⇒ K:=T∪ {n+1} ⊆ {1, . . . ,n+2} is a solution for PARTITION with inputsa1, . . .an+2. (same argument can be done for T∪ {n+2}but by construction a solution can’t containn+1andn+2)

proof:

• ⇒LetK⊆ {1, . . . ,n+2}be a solution for PARTITION of the formK=T∪ {n+1}with inputsa1, . . .an+2. We get P

kKak=P

k/Kak

⇔ P

k∈K\{n+1}ak+Mb+1=P

k∈K\{n+2}/ ak+b+1

⇔ P

kK\{n+1}ak+Pn

k=1ak−P

k/K\{n+2}ak=2b

⇔ P

kK\{n+1}ak+P

kK\{n+1}ak=2b

⇔ 2P

k∈K\{n+1}ak=2b.

HenceT=K\ {n+1}is a solution for SUBSETSUM.

• ⇐LetT⊆ {1, . . . ,an}be a solution for SUBSETSUM. ThenK=T∪ {n+1}is a solution for PARTITION because of

X

kK

ak=Mb+1+X

kT

ak=1+

n

X

k=1

ak

=1+X

k∈T

ak+X

k/T

ak=1+b+X

k/T

ak

=X

k/K

ak.

Notice thatT⊆ {1, . . . ,n}andK⊆ {1, . . . ,n+2}.

Referenzen

ÄHNLICHE DOKUMENTE

Furthermore, we have no reason to believe that M of our wire samples is smaller than in bulk samples as magnetic properties like T C (derived from the temperature dependence of

Verifizieren Sie Ihre Aussagen anhand selbst gew¨ ahlter Testrechnungen.. Abgabe

Informieren Sie sich über die mittlere Lebensdauer von Myonen und überprüfen Sie, ob die Myonen auf der Erde detektiebar sind, wenn relativistische Effekte ignoriert werden.

They describe the number of possibilities to choose k objects from a given set containing n objects (without putting objects back and without respecting the order of the

They describe the number of possibilities to choose k objects from a given set containing n objects (without putting objects back and without respecting the order of the

that this denes a monoidal equivalence of categories. Describe the group valued functor K -c Alg

Mathematische Grundlagen der Informatik RWTH

Five of them provided data on wind speed and direction,air temperature, the temperature inside the hull and atmospheric pressure.. One buoy carried a