Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Quiz 4 - CSE 260 (Fall 2001) - Finite State Machines and Grammar, Quizzes of Discrete Structures and Graph Theory

Information about quiz 4 for the cse 260 (fall 2001) course. It includes instructions and examples for drawing state diagrams of finite machines with outputs based on current and previous input symbols, constructing phrase-structured grammars, and generating parse trees for given expressions. The quiz covers topics such as finite state machines, grammar, and parsing.

Typology: Quizzes

Pre 2010

Uploaded on 07/28/2009

koofers-user-ru2-1
koofers-user-ru2-1 🇺🇸

10 documents

1 / 7

Toggle sidebar

Related documents


Partial preview of the text

Download Quiz 4 - CSE 260 (Fall 2001) - Finite State Machines and Grammar and more Quizzes Discrete Structures and Graph Theory in PDF only on Docsity! CSE 260 (Fall 2001 Sec 1) Quiz 4a 8 Nov Name: 1. (10 pts) Draw the state diagram of a finite machine with output that outputs the exclusive or of the current input symbol and the previous input symbol. The input and output alphabets are both {0, 1}. The machine should always output a 0 after the first symbol is read. 2. (10 pts) Construct a phrase-structured grammer to generate the set of strings {02n1 | n ≥ 0}. You only need to list the productions in the grammar. 1 3. (10 pts)                                  Z Z Z Z Z Z Z Z     HHHHHH HH HH H s0 s1 s8 s4 s5 s7 s6 s3 s2 1 0 0 1 s9 1 0 0 1 0 1 0 1 0 1 0 Start 0,1 1 0 1 For each string, indicate if it is accepted by the above finite- state automata. (a) 0101 (b) 11101010 (c) 11111 (d) 10110101 4. (10 pts) Using the grammar below, contruct a complete parse tree (derivation tree) for the expressions on the following page. S −→ E E −→ T // a term in an expression E −→ E + T // addition E −→ E − T // subtraction T −→ F // a factor is a term T −→ T ∗ F // multiplication T −→ T/F // division F −→ I // a variable name, such as (i,j,a,b,etc ) F −→ U // an unsigned number, such as 0 1,2,3,4,5, etc. F −→ (E) // a paranthesized expression F −→ I[E] // an array reference I −→ i // variable names I −→ j I −→ a I −→ b U −→ 2 // integers U −→ 5 // integers 2 CSE 260 (Fall 2001 Sec 1) Quiz 4b 8 Nov Name: 1. (10 pts) Draw the state diagram of a finite machine with output that outputs a 1 if the current input symbol and the previous input symbol are the same, and a 0 otherwise. The input and output alphabets are both {0, 1}. The machine should always output a 0 after the first symbol is read. 2. (10 pts) Construct a phrase-structured grammer to generate the set of strings {13n0 | n ≥ 0}. You only need to list the productions in the grammar. 5 3. (10 pts)                                  Z Z Z Z Z Z Z Z     HHHHHH HH HH H s0 s1 s8 s4 s5 s7 s6 s3 s2 1 0 0 1 s9 1 0 0 1 0 1 0 1 0 1 0 Start 0,1 1 0 1 For each string, indicate if it is accepted by the above finite- state automata. (a) 01001 (b) 0000 (c) 011111 (d) 101101111 4. (10 pts) Using the grammar below, contruct a complete parse tree (derivation tree) for the expressions on the following page. S −→ E E −→ T // a term in an expression E −→ E + T // addition E −→ E − T // subtraction T −→ F // a factor is a term T −→ T ∗ F // multiplication T −→ T/F // division F −→ I // a variable name, such as (i,j,a,b,etc ) F −→ U // an unsigned number, such as 0 1,2,3,4,5, etc. F −→ (E) // a paranthesized expression F −→ I[E] // an array reference I −→ i // variable names I −→ j I −→ a I −→ b U −→ 1 // integers U −→ 5 // integers 6 a + b * 5 b [ i - 1 ] * ( i + j ) 7
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved