Automata and compiler, Theory of Computation

Assignment Help:

Automata and Compiler

(1) [25 marks] Let N be the last two digits of your student number. Design a finite automaton that accepts the language of strings that end with the last four bits of the binary expansion of N. (1.1) Make a regular expression ? of this language. For example the set of strings that end with 101 is expressed by a regular expression (0+1)*101. (1.2) Make an NFA that accepts this expression ?. You should remove any ?-moves that can be done trivially by inspection. (1.3) Make a subset automaton that accepts the language. (1.4) Perform state minimization on the above automaton.

(2) [25 marks] A CFG is given by S ? aSbS, S ? bSaS, S ? c

(2.1) Draw a syntax chart for this grammar. [5]

(2.2) Write a Python program for the recursive descent parser Trace the parser using two strings of at least 10 symbols, one for an accepted case and one for an unaccepted case. Do the trace using the style in the notes. [20]

(3) [25 marks] A sample program for computing the greatest common divisor by recursive call and its object program are given below. Some sample comments are given.

const a=75, b=55;

var x, y;

procedure gcd;

var w;

begin

if y>0 then begin

w:=y;

y:=x ? (x/y)*y;

x:=w;

call gcd;

end;

end;

begin

x:=a; y:=b;

call gcd;

write(x);

end.

0 jmp 0 21 Jump to 21, start of main

1 jmp 0 2

2 inc 0 4

3 lod 1 4

4 lit 0 0 Load literal 0

5 opr 0 12 Test if y>0

6 jpc 0 20 Jump to 20 if false

7 lod 1 4 Load y

8 sto 0 3 Store in w

9 lod 1 3

10 lod 1 3

11 lod 1 4

12 opr 0 5

13 lod 1 4

14 opr 0 4

15 opr 0 3

16 sto 1 4

17 lod 0 3

18 sto 1 3

19 cal 1 2

20 opr 0 0

21 inc 0 5

22 lit 0 75

23 sto 0 3

24 lit 0 55

25 sto 0 4

26 cal 0 2

27 lod 0 3

28 wrt 0 0 Write stack top

29 opr 0 0


Related Discussions:- Automata and compiler

Find a regular expression, Find a regular expression for the regular langua...

Find a regular expression for the regular language L={w | w is decimal notation for an integer that is a multiple of 4}

Reducibility among problems, A common approach in solving problems is to tr...

A common approach in solving problems is to transform them to different problems, solve the new ones, and derive the solutions for the original problems from those for the new ones

Numerical integration, what problems are tackled under numerical integratio...

what problems are tackled under numerical integration

Give a strictly 2-local automaton, Let L 3 = {a i bc j | i, j ≥ 0}. Give ...

Let L 3 = {a i bc j | i, j ≥ 0}. Give a strictly 2-local automaton that recognizes L 3 . Use the construction of the proof to extend the automaton to one that recognizes L 3 . Gi

TRANSPORTATION, DEGENERATE OF THE INITIAL SOLUTION

DEGENERATE OF THE INITIAL SOLUTION

Convert chomsky normal form into binary form, Suppose G = (N, Σ, P, S) is a...

Suppose G = (N, Σ, P, S) is a reduced grammar (we can certainly reduce G if we haven't already). Our algorithm is as follows: 1. Define maxrhs(G) to be the maximum length of the

Path function of a nfa, The path function δ : Q × Σ* → P(Q) is the extensio...

The path function δ : Q × Σ* → P(Q) is the extension of δ to strings: This just says that the path labeled ε from any given state q goes only to q itself (or rather never l

Myhill graphs, Another way of representing a strictly 2-local automaton is ...

Another way of representing a strictly 2-local automaton is with a Myhill graph. These are directed graphs in which the vertices are labeled with symbols from the input alphabet of

Decision Theroy, spam messages h= 98%, m= 90%, l= 80% non spam h=12%, m = 8...

spam messages h= 98%, m= 90%, l= 80% non spam h=12%, m = 8%, l= 5% The organization estimates that 75% of all messages it receives are spam messages. If the cost of not blocking a

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd