Sunteți pe pagina 1din 6

MC0082 Theory of Computer Science

(Book ID: B0970)

Set-1

1. Prove by the method of mathematical induction that:

Ans:1 Base Step: Let n=0 then the sum of the left side is 0 Since there is nothing to add the expression on the right side is also 0 If n=1 then left side is 1 & right side =

12 (1 + 1) 2 =1 4

Hence the result is true for n=1 Induction Hypothesis: Assume that the result to be true for n=m then

13 + 2 3 + ... + m 3 =

m 2 (m + 1) 2 4 m 2 ( m + 1) 2 + (m + 1) 3 4 ( m + 1) 2 {m 2 + 4( m + 1)} 4 ( m + 1) 2 {m 2 + 4m + 4} 4 ( m + 1) 2 (m + 2) 2 4 ( m + 1) 2 ( m + 2) 2 4

Adding the (m+1)th term i.e (m+1)3 to both side of the above equation

13 + 2 3 + ... + m 3 + ( m + 1) 3 = = =

= =

There for the result is true for n=m+1. Hence the mathematical induction, the given result is true for all positive integer n.

2. Construct a grammer for the language: L = { x/x {a, b}, the number of as in x is a multiple of 3} Ans:2

MC0082 Theory of Computer Science


(Book ID: B0970)

3. Prove that the sum of the degrees of the vertices of a graph G is twice the number of edges. Ans:3 Let G is a connected graph. If G has no circuit, then G is a spanning tree. If G has a circuit, then delete an edge from this circuit. If till leaves the graph connected. If there are more circuits, repeat the operation till an edge from the last circuit is deleted, Leaving the graph connected, circuit less and contain all the vertices of G thus the sub graph obtained a spanning tree of G. Hence every connected graph has at least one spanning tree. Then a graph G is connected if and only if it has a spanning tree is ture.

MC0082 Theory of Computer Science


(Book ID: B0970)
4. Obtain a DFA to accept strings of as and bs starting with the string ab. Ans:4 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

MC0082 Theory of Computer Science


(Book ID: B0970)

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.

5. Write briefly about the concept of Deterministic Finite Automata (DFA). Ans:5 A DFA is a 5-tuple or quintuple M=(Q, _, , q0, F) Q is non-empty, finite set of states. _ is non-empty, finite state set of input alphabet. is transition function, which is mapping from Q X _ to Q. for this transition function the parameters to be passed are state and input symbols. Based on the current state and input symbols, the machine may enter into another state. q0 Q is the start state. F Q is a set of accepting or final state. Note: for each input symbol a, from a given state there is exactly one transition and we are sure to which state the machine enters. So the machine is called Deterministic Machine. 6. Convert the Moore machine M1 whose state table is given in table below into an equivalent Mealy machine. Moore Machine Next State Input a=0 Q1 Q3 Input a=1 Q2 Q2

Present State Q0 Q1

Output 1 0

MC0082 Theory of Computer Science


(Book ID: B0970)
Q2 Q3 Q2 Q0 Q1 Q3 1 1

Ans:6 Conversion of Mealy Machine into Moore Machine: Consider the following steps Step 1: For a state qi determine the number of outputs that are available in state table of the Mealy machine. Step 2:If the outputs corresponding to state qi in the next state columns are same, then retain state qi as it is. Else, break qi into different states with the number of new states being equal to the number of different outputs of qi. Step 3:Rearrange the states and outputs in the format of Moore machine. The common output of the new state table can be determined by examining the outputs under the next state columns of the Mealy machine. Step 4:If the output in the constructed state table corresponding to the initial state is 1, then this specifies the acceptance of the null string ^ by Mealy machine. Hence, to make both the Mealy and Moore machines equivalent, we either need to ignore the corresponding to null string or we need to insert a new initial state at beginning whose output os 0; the other row elements in this case would remain the same. Let us first transform each column of inputs into the pairs of the next state and the output as shown in the following table. Present State Input a = 0 Input a = 1 State Output State Output q0 q1 0 q2 1 q1 q3 1 q2 1 q2 q2 1 q1 0 q3 q0 1 q3 1 Since there are no two states in the above state table which have identical row elements, the state table as shown represents the equivalent Mealy machine for the Moore machine depicted above.

MC0082 Theory of Computer Science


(Book ID: B0970)

S-ar putea să vă placă și