BC0052-Fall Drive Assignments 2012

17
BCA Revamped PROGRAMME V th SEMESTER ASSIGNMENTS-01 Name : Register no. : Learning center : Learning center code : Course / Program : Semester : Subject code : Subject Title : Date of submission : Date of submission : Marks awarded : Average marks of both assignments Signature of center coordinator Signature of Evaluator Directorate of Distance Education Sikkim Manipal UniversityII Floor, Syndicate House, Manipal-576 104

Transcript of BC0052-Fall Drive Assignments 2012

Page 1: BC0052-Fall Drive Assignments 2012

BCA Revamped PROGRAMMEVth SEMESTERASSIGNMENTS-01

Name :

Register no. :

Learning center :

Learning center code :

Course / Program :

Semester :

Subject code :

Subject Title :

Date of submission :

Date of submission :

Marks awarded :

Average marks of both assignments

Signature of center coordinator Signature of Evaluator

Directorate of Distance EducationSikkim Manipal UniversityII Floor, Syndicate House, Manipal-576 104

1. Show that the relationis a ≡ b(mod m ) equivalence relation.

Answer

Page 2: BC0052-Fall Drive Assignments 2012
Page 3: BC0052-Fall Drive Assignments 2012

Answer

Page 4: BC0052-Fall Drive Assignments 2012

Answer

Page 5: BC0052-Fall Drive Assignments 2012

Answer

i. Base Step: Let n = 0. Then the sum on the left is zero, since there is

nothing to add. The expression on the right is also zero

Therefore the result is true for n= m+1. Hence by mathematical induction the given result is true for all positive integers n

Page 6: BC0052-Fall Drive Assignments 2012

Answer

(The proof is by induction on the number of edges ‘e‘).

Case-(i): Suppose e = 1. Suppose f is the edge in G with f = uv.

Then d(v) = 1, d(u) = 1. Therefore

Hence by induction we get that “the sum of the degrees of the vertices of the graph G is twice the numbers of edges”.

Page 7: BC0052-Fall Drive Assignments 2012

Answer

Part 1: Suppose T is a tree. Then T is a connected graph and contains no circuits.

Since T is connected, there exists at least one path between every pair of vertices in T.

Suppose that between two vertices a and b of T, there are two distinct paths.

Now, the union of these two paths will contain a circuit in T, a contradiction (since T contains no circuits).

This shows that there exists one and only one path between a given pair of vertices in T.

Part 2: Let G be a graph.

Assume that there is one and only one path between every pair of vertices in G.

This shows that G is connected.

If possible suppose that G contains a circuit.

Then there is at least one pair of vertices a, b such that there are two distinct paths between a and b. But this is a contradiction to our assumption.

So G contains no circuits. Thus G is a tree.

Page 8: BC0052-Fall Drive Assignments 2012

1. Prove that “A tree G with n vertices has (n–1) edges”

Answer

We prove this theorem by induction on the number vertices n.

Basic step: If n = 1, then G contains only one vertex and no edge. So the number of edges in

G is n –1 = 1 – 1 = 0.

Induction hypothesis: The statement is true for all trees with less than ‘n’ vertices. Induction step: Now let us consider a tree with ‘n’ vertices. Let ‘ek’ be any edge in T whose end vertices are vi and vj. Since T is a tree, by there is no other path between vI and vj. So by removing ek from T, we get a disconnected graph. Furthermore, T- ekconsists of exactly two components (say T1 and T2). Since T is a tree, there were no circuits in T and so there were no circuits in T1 and T2. Therefore T1 and T2 are also trees.

It is clear that |V(T1)| + |V(T2)| = |V(T)| where V(T) denotes the set of vertices in T.

Also |V(T1)| and |V(T2)| are less than n.

Therefore by the induction hypothesis, we have

|E(T1)| = |V(T1)| - 1 and |E(T2)| = |V(T2)| - 1.

|E(T1)| = |V(T1)| - 1 and |E(T2)| = |V(T2)| - 1.

Page 9: BC0052-Fall Drive Assignments 2012

Answer

Page 10: BC0052-Fall Drive Assignments 2012

3. Obtain a DFA to accept strings of a’s and b’s starting with the string ab.

Answer

It is clear that the string should start with ab and so, the minimum string that can be accepted by the machine is ab.

To accept the string ab, we need three states and the machine can be written as

where q2 is the final or accepting state. In state q0, if the input symbol is b, the machine should reject b (note that the string should start with a). So, in state q0, on input b, we enter into the rejecting state q3. The machine for this can be of the form

The machine will be in state q1, if the first input symbol is a. If this a is followed by another a, the string aa should be rejected by the machine. So, in state q1, if the input symbol is a, we reject it and enter into q3 which is the rejecting state. The machine for this can be of the form

Whenever the string is not starting with ab, the machine will be in state q3 which is the rejecting state. So, in state q3, if the input string consists of a‟s and b‟s of any length, the entire string can be rejected and can stay in state q3 only.

Page 11: BC0052-Fall Drive Assignments 2012

The resulting machine can be of the form

The machine will be in state q2, if the input string starts with ab. After the string ab, the string containing any combination of a‟s and b‟s, can be accepted and so remain in state q2 only. The complete machine to accept the strings of a‟s and b‟s starting with the string ab is shown in figure.The state q3 is called trap state or rejecting state.

In the set notation, the lang uage accepted by DFA can be represented as

Page 12: BC0052-Fall Drive Assignments 2012
Page 13: BC0052-Fall Drive Assignments 2012

4. Briefly describe Moore and Mealy machines

Answer

Page 14: BC0052-Fall Drive Assignments 2012

Answer

i) Consider the string: aaab

Therefore the string „aaab’ is not accepted by M.

ii) Consider the string: bbaa

Therefore „bbaa’ is not accepted by M.

iii) State diagram:

Page 15: BC0052-Fall Drive Assignments 2012
Page 16: BC0052-Fall Drive Assignments 2012

Answer

string consisting of 0‟s and l‟s can be represented by the regular expression

(0 + 1)*

This arbitrary string can precede three consecutive zeros and can follow three consecutive zeros. Therefore the regular expression can be written as

(0 +1)* 000(0+1)*.

The language corresponding to the regular expression can be written as