• Nem Talált Eredményt

Give CF-grammar for the following languages

N/A
N/A
Protected

Academic year: 2022

Ossza meg "Give CF-grammar for the following languages"

Copied!
2
0
0

Teljes szövegt

(1)

Theory of Algorithms 2019 Practice session 4.

1. Let the grammar be S →AB A→0A1|01 B →1B0|10.

(a) Give a parse tree for word001110.

(b) Determine the language generated by this grammar.

2. Consider S→AS|A A→0A1|01.

(a) Give a parse tree and a leftmost derivation for word 01010011.

(b) Determine the language generated by this grammar.

3. Give CF-grammar for the following languages. Are these unambiguous?

(a) L={anbn+1:n≥0}

(b) L={anb2n:n≥0}

(c) Palindromes over {a,b}

(d) L={aibjck:i=j ori=ki, j, k≥0}

4. Are the following grammars unambiguous? Are the languages generated by them unambiguous?

(a) S →aSa|bSb|aa|bb|a|b

(b) S →T T|U T →0T|T0|# U →0U00|#

5. Let the alphabet be Σ = {0,1}, states of the pushdown automaton be Q = {A, B, C}, where A is the start state and C is the only accept state, let Z be the start symbol of the stack. The transition function is the following. δ(A,0, ε) = {(A, a)}, δ(A,1, ε) = {(A, b)}, δ(A, ε, ε) = {(B, ε)}, δ(B,0, a) = {(B, ε)}, δ(B,1, b) ={(B, ε)},δ(B, ε, Z) ={(C, ε)}.

(a) Give the possible computations of the automaton on word010.

(b) Does it accept word 0110?

(c) What is the language recognized by the automaton?

(d) Give a CF-grammar for this language.

6. Construct a pushdown automaton for the language of palindromes.

7. Create pushdown automata for the following languages.

(a) La={aibjck:i, j, k ≥0 andi+j=k}

(b) Lb={aibjck:i, j, k≥0 and j+k=i}

(c) Lc={aibjck:i, j, k≥0 andi+k=j}

8. Create a pushdown automaton for the language of proper parenthesisations.

9. Construct pushdown automata for the following languages.

(a) La={anbm: 2n=m≥1}

(b) Lb={anbm : 2n≥m≥n≥1}

10. Create a pushdown automaton from the following CF-grammar. S → aSa |bSb| aa |bb | a |b Give an accepting computation for the word ababa (if such a computation exists).

11. Consider the unambiguous CF- grammar given in the lecture for the arithmetic expressions.

(a) Give a parse tree for the word a+a+a+a.

(b) If the value of the expression is calculated using the parse tree, then in what order will the additions be executed?

(c) Extend the grammar so that substraction is also included. is szerepeljen benne!

(d) What is the parse tree ofa−a+a−anow? What is the order of execution of the operations?

(2)

12. Give a CF-grammar that generates all such proper expressions that contain multiplications, exponentations and parentheses. The grammar should be unambiguous and should confirm to the usual order of execution of operations (that is, without parentheses exponentation has precedence, and for example in case of 234 first 34 must be computed and then it will be the exponent of 2).

Hivatkozások

KAPCSOLÓDÓ DOKUMENTUMOK

It should be noted that in the case of the ideal system, friction is accounted for in the model. The ideal param- eters were selected in terms of friction and inertia. It is

Major research areas of the Faculty include museums as new places for adult learning, development of the profession of adult educators, second chance schooling, guidance

Any direct involvement in teacher training comes from teaching a Sociology of Education course (primarily undergraduate, but occasionally graduate students in teacher training take

The decision on which direction to take lies entirely on the researcher, though it may be strongly influenced by the other components of the research project, such as the

By examining the factors, features, and elements associated with effective teacher professional develop- ment, this paper seeks to enhance understanding the concepts of

In the case of a-acyl compounds with a high enol content, the band due to the acyl C = 0 group disappears, while the position of the lactone carbonyl band is shifted to

John then moves to the embedded [Spec, IP] position to check the EPP feature of to; the Case of John is not checked here, as no Case is assigned to the embedded subject position

With the help of their practice book and in some papers the authors of the grammar patterns series also try to give ideas to teachers and learners of English in