You are on page 1of 16

BCA Revamped PROGRAMME Vth 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

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

Answer

Answer

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

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.

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.

1. Prove that A tree G with n vertices has (n1) 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.

Answer

3. Obtain a DFA to accept strings of as and bs 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 as and bs of any length, the entire string can be rejected and can stay in state q3 only.

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 as and bs, can be accepted and so remain in state q2 only. The complete machine to accept the strings of as and bs 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

4. Briefly describe Moore and Mealy machines Answer

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:

Answer
string consisting of 0s and ls 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

You might also like