mc0082 set2 killer assignment 2012

12
Spring 2012 Master of Computer Application (MCA) – Semester V MC0082 – THEORY OF COMPUTER SCIENCE (Book ID: B0970) Assignment Set – 2 1.Prove that any connected graph with n vertices and n – 1 edges is a tree. Answer: For a given graph G, with n vertices the following conditions are equivalent: i) G is connected and is circuitless; ii) G is connected and has n –1 edges; iii) G is circuitless and has n –1 edges; iv) There is exactly one path between every pair of vertices in G; v) G is a tree. 2. Construct a grammer for the language L = {aaaa, aabb, bbaa, bbbb} Answer:

Transcript of mc0082 set2 killer assignment 2012

Page 1: mc0082 set2 killer assignment 2012

Spring 2012 Master of Computer Application (MCA) – Semester V MC0082 – THEORY OF COMPUTER SCIENCE (Book ID: B0970) Assignment Set – 2

1.Prove that any connected graph with n vertices and n – 1 edges is a tree. Answer:

For a given graph G, with n vertices the following conditions are equivalent: i) G is connected and is circuitless;

ii) G is connected and has n –1 edges;

iii) G is circuitless and has n –1 edges;

iv) There is exactly one path between every pair of vertices in G;

v) G is a tree.

2. Construct a grammer for the language L = {aaaa, aabb, bbaa, bbbb}Answer:

Page 2: mc0082 set2 killer assignment 2012

3.Briefly write in your own words the concept of transition graph. Answer:

Transition System (Transition graph) A finite directed labeled graph in which each node or vertex of the graph represents a state and the directed edges from one node to another represent transition of a state. All the edges of the transition graph are labeled as input/output. For example, an edge labeled 1/0 specifies that for a certain initial state if the input is 1, then the output is 0. Consider the following diagram: In the transition graph as shown in the figure, The initial state, q0, of the system is represented by a circle with an arrow pointing towards it.

The final state, q1, is represented by two concentric circles.

The directed edges from the initial state to the final state are labeled as input/output.

Page 3: mc0082 set2 killer assignment 2012

Example:

Page 4: mc0082 set2 killer assignment 2012

4. Explain the steps involved in the conversion of Mealy machine into Moore Machine. Ansawe:Conversion of Mealy machine into Moore Machine Consider the following steps Step 1: For a state qi determine the number of different 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 a Moore machine. The common output of the new state table can be determined by examining the outputs under the next state columns of the original 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 output corresponding to the null string or we need to insert a new initial state at the beginning whose output is 0; the other row elements in this case would remain the same. Consider the following example, to convert a given mealy machine into a Moore machine.

Page 5: mc0082 set2 killer assignment 2012

5. Differentiate between DFA and NDFA.

Answer:Deterministic Finite Automata (DFA)

Page 6: mc0082 set2 killer assignment 2012
Page 7: mc0082 set2 killer assignment 2012

Nondeterministic Finite Automata(NdFA)

Page 8: mc0082 set2 killer assignment 2012
Page 9: mc0082 set2 killer assignment 2012

6.Construct a DFA and the transition diagram , to accept the language generated by the following grammar

Answer:

Page 10: mc0082 set2 killer assignment 2012