Question 1 (10%) Consider the following grammar
S→D|DS
D→0|1|2|3|4|5|6|7|8|9
(a) Write a left most derivation of the string 7801.
(b) Write a right most derivation of the string 7801.
a) S -> DS -> 7S -> 7DS -> 78S -> 78DS -> 780S -> 780D -> 7801 b) S -> DS -> DDS -> DDDS -> DDDD -> DDD1 -> DD01 -> D801 -> 7801

Question 1 (10%) Consider the following grammar S→D|DS D→0|1|2|3|4|5|6|7|8|9 (a) Write a left most derivation of...
Write the left-most derivation for the following ALGOL statement using the provided Partial grammar. if k< 1 then A/B else B/A (Boolean expression) ::= (simple Boolean) | (if clause)(simple Boolean) else (Boolean expression) (arithmetic expression) ::= (simple arithmetic expression) | (if clause)(simple arithmetic expression) else (arithmetic expression) (if clause) .:= if (Boolean expression) then (simple arithmetic expression) ::= A/B | B/A (simple Boolean) ::= k< 1 | a > 0 it
Question 1 Consider the following BNF grammar: Not complete Marked out of 3.00 p Flag question <letter> ::= "a" | "b" | "C" | "d" | "e" | "F" | "g" | "h" | "1" ";" | "K" | "1" | "m" | "n" | "0" | "p" | "q" | "r" | "S" | "t" || "u" | "V" | "W" | "x" | "y" | "z" <digit> ::= "O" | "1" | "2" | "3" | "4" |...
1.a Consider the following Grammar, <assign> à <id> = <expr> <id> à A | B |C <expr> à < expr> + <expr> | <expr> * <expr> | ( <expr> ) | <id> Derive the following statement using leftmost derivation. A = A * (B*(C+ A)) b. 2 a}. Consider the following grammar that expresses parenthesized expressions of digits, including both addition and multiplication. <expr> := <expr> + <expr> | <expr> * <expr> | (expr>) | <digit> <digit> := 0 | 1 | 2 |...
0 Q1 D lf S- {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} and A-|0, 2, 4, 6, 8], B (1, 3, 5, 7,9), С (2, 3, 4, 5), and [1,6,7], list the elements of the sets corresponding to the following events: (a) A U C; (b) A n B; (d) (C' n D) U B; (e) (s n c)' (f) Anc n D'.
3 points) Question Three Consider the context-free grammar S >SS+1 SS 1a and the string aa Give a leftmost derivation for the string. 3 points) (4 poiots) (5 points) (3 points) sECTION IWOLAttcmpt.any 3.(or 2) questions from this.scction Suppose we have two tokens: (1) the keyword if, and (2) id-entifiers, which are strings of letters other than if. Show the DFA for these tokens. Give a nightmost derivation for the string. Give a parse tree for the string i) Is...
1. Consider the following grammar A - aB B-Sb (a) Show a derivation tree for the string aabbbb using the grammar. (b) Give an English description of the language generated by the grammar 2. Let G be the grammar below: S-ASB ab | SS (a) Show that G is ambiguous. (b) Construct an unambiguous grammar equivalent to G. 3. Find a context free grammar for the language L3- fa"b"c+m :n,m21) 4. Find a context free grammar for the language L4...
Q1 lf S-(Q 1, 2, 3, 4, 5, 6, 7, 8, 9} and A-|0, 2, 4, 6, 8], B (1, 3, 5, 7, 9), C (2, 3, 4, 5), and D [1,6,7], list the elements of the sets corresponding to the following events: (a) A U C; (b) An B; (d) (C' n D) U B; (e) (s n c)' (f) Anc n D'.
Let U = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} be the universal set. Consider the two subsets A = {0, 2, 4, 6, 8} and B = {0,3,6,9}. Use the roster method to write each of the following sets (a) AUB. (b) An B. (c) AC. (d) (AUB) – AC
Given the following sets: S = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, Even numbers A = {2, 4, 6, 8, 10}; Odd number B = {3, 5, 7, 9}; Natural numbers N = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} and Prime numbers C = {2, 3, 5, 7} Find the following: a) A ∪ C b) A ∩ N c) A ’ d) B ∩ N e) B ∪ N f) C...
(1) Write the permutation 1 2 3 4 5 6 7 8 9 10 7 5 10 3 8 9 6 2 4 ( 10 1 as a product of disjoint cycles.