CSE : Exam 3-ANSWERS, Spring 2011 Time: 50 minutes

Similar documents
1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true.

Assignment 1 Automata, Languages, and Computability. 1 Finite State Automata and Regular Languages

Formal languages, automata, and theory of computation

The University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 2 MODULE, SPRING SEMESTER LANGUAGES AND COMPUTATION ANSWERS

CS 373, Spring Solutions to Mock midterm 1 (Based on first midterm in CS 273, Fall 2008.)

Harvard University Computer Science 121 Midterm October 23, 2012

Name Ima Sample ASU ID

CS 310 (sec 20) - Winter Final Exam (solutions) SOLUTIONS

First Midterm Examination

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true.

Regular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Kleene-*

Homework 3 Solutions

Chapter 2 Finite Automata

CMPSCI 250: Introduction to Computation. Lecture #31: What DFA s Can and Can t Do David Mix Barrington 9 April 2014

Compiler Design. Fall Lexical Analysis. Sample Exercises and Solutions. Prof. Pedro C. Diniz

Minimal DFA. minimal DFA for L starting from any other

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton

80 CHAPTER 2. DFA S, NFA S, REGULAR LANGUAGES. 2.6 Finite State Automata With Output: Transducers

Exercises Chapter 1. Exercise 1.1. Let Σ be an alphabet. Prove wv = w + v for all strings w and v.

SWEN 224 Formal Foundations of Programming WITH ANSWERS

Languages & Automata

Anatomy of a Deterministic Finite Automaton. Deterministic Finite Automata. A machine so simple that you can understand it in less than one minute

378 Relations Solutions for Chapter 16. Section 16.1 Exercises. 3. Let A = {0,1,2,3,4,5}. Write out the relation R that expresses on A.

Formal Languages and Automata

a,b a 1 a 2 a 3 a,b 1 a,b a,b 2 3 a,b a,b a 2 a,b CS Determinisitic Finite Automata 1

First Midterm Examination

Finite-State Automata: Recap

Nondeterminism and Nodeterministic Automata

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

1.4 Nonregular Languages

Talen en Automaten Test 1, Mon 7 th Dec, h45 17h30

CSC 311 Theory of Computation

Designing finite automata II

CISC 4090 Theory of Computation

Overview HC9. Parsing: Top-Down & LL(1) Context-Free Grammars (1) Introduction. CFGs (3) Context-Free Grammars (2) Vertalerbouw HC 9: Ch.

FABER Formal Languages, Automata and Models of Computation

Non Deterministic Automata. Linz: Nondeterministic Finite Accepters, page 51

Non-Deterministic Finite Automata. Fall 2018 Costas Busch - RPI 1

CS 301. Lecture 04 Regular Expressions. Stephen Checkoway. January 29, 2018

Convert the NFA into DFA

3 Regular expressions

Formal Language and Automata Theory (CS21004)

Finite Automata-cont d

1 Nondeterministic Finite Automata

Let's start with an example:

Regular expressions, Finite Automata, transition graphs are all the same!!

Context-Free Grammars and Languages

NFA DFA Example 3 CMSC 330: Organization of Programming Languages. Equivalence of DFAs and NFAs. Equivalence of DFAs and NFAs (cont.

State Minimization for DFAs

CS 311 Homework 3 due 16:30, Thursday, 14 th October 2010

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. Comparing DFAs and NFAs (cont.) Finite Automata 2

Deterministic Finite Automata

1.3 Regular Expressions

CHAPTER 1 Regular Languages. Contents

Model Reduction of Finite State Machines by Contraction

Revision Sheet. (a) Give a regular expression for each of the following languages:

CMSC 330: Organization of Programming Languages

Closure Properties of Regular Languages

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. NFA for (a b)*abb.

For convenience, we rewrite m2 s m2 = m m m ; where m is repeted m times. Since xyz = m m m nd jxyj»m, we hve tht the string y is substring of the fir

Scanner. Specifying patterns. Specifying patterns. Operations on languages. A scanner must recognize the units of syntax Some parts are easy:

Speech Recognition Lecture 2: Finite Automata and Finite-State Transducers

Chapter Five: Nondeterministic Finite Automata. Formal Language, chapter 5, slide 1

CS375: Logic and Theory of Computing

NFAs and Regular Expressions. NFA-ε, continued. Recall. Last class: Today: Fun:

Theory of Computation Regular Languages

Homework Solution - Set 5 Due: Friday 10/03/08

CS:4330 Theory of Computation Spring Regular Languages. Equivalences between Finite automata and REs. Haniel Barbosa

Theory of Computation Regular Languages. (NTU EE) Regular Languages Fall / 38

input tape head moves current state

Some Theory of Computation Exercises Week 1

Converting Regular Expressions to Discrete Finite Automata: A Tutorial

CS103B Handout 18 Winter 2007 February 28, 2007 Finite Automata

5. (±±) Λ = fw j w is string of even lengthg [ 00 = f11,00g 7. (11 [ 00)± Λ = fw j w egins with either 11 or 00g 8. (0 [ ffl)1 Λ = 01 Λ [ 1 Λ 9.

Lexical Analysis Finite Automate

CS 330 Formal Methods and Models

Finite Automata. Informatics 2A: Lecture 3. John Longley. 22 September School of Informatics University of Edinburgh

Linear Inequalities. Work Sheet 1

GNFA GNFA GNFA GNFA GNFA

Homework 4. 0 ε 0. (00) ε 0 ε 0 (00) (11) CS 341: Foundations of Computer Science II Prof. Marvin Nakayama

Regular Language. Nonregular Languages The Pumping Lemma. The pumping lemma. Regular Language. The pumping lemma. Infinitely long words 3/17/15

Coalgebra, Lecture 15: Equations for Deterministic Automata

CSC 473 Automata, Grammars & Languages 11/9/10

Worked out examples Finite Automata

CHAPTER 1 Regular Languages. Contents. definitions, examples, designing, regular operations. Non-deterministic Finite Automata (NFA)

DFA Minimization and Applications

Thoery of Automata CS402

CS415 Compilers. Lexical Analysis and. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University

Recursively Enumerable and Recursive. Languages

Finite Automata. Informatics 2A: Lecture 3. Mary Cryan. 21 September School of Informatics University of Edinburgh

NFAs continued, Closure Properties of Regular Languages

Grammar. Languages. Content 5/10/16. Automata and Languages. Regular Languages. Regular Languages

CS 275 Automata and Formal Language Theory

3. Finite automata and regular languages: theory

E 1 (n) = E 0 (n-1) E 0 (n) = E 0 (n-1)+e 0 (n-2) T(n -1)=2E 0 (n-2) + E 0 (n-3)

Non-deterministic Finite Automata

Table of contents: Lecture N Summary... 3 What does automata mean?... 3 Introduction to languages... 3 Alphabets... 3 Strings...

PART 2. REGULAR LANGUAGES, GRAMMARS AND AUTOMATA

CSCI FOUNDATIONS OF COMPUTER SCIENCE

NFAs continued, Closure Properties of Regular Languages

Transcription:

CSE 260-002: Exm 3-ANSWERS, Spring 20 ime: 50 minutes Nme: his exm hs 4 pges nd 0 prolems totling 00 points. his exm is closed ook nd closed notes.. Wrshll s lgorithm for trnsitive closure computtion is sed on dynmic progrmming which uses the following recursive formul: i,j,k n w [k] ij = w [k ] ij (w [k ] ik w [k ] kj ) Bsed on the ove recursive formul, Wrshll s lgorithm is written s follows: W = M R ; M R is the 0- mtrix for the reltion R. or k= to n do the following: or i= to n do the following: or j= to n do the following: w ij = w ij (w ik w kj ) Let W k e the zero-one mtrix produced in the kth. itertion. () (5 points) Wht do the logicl opertions on the right hnd side of the following sttement ccomplish in computing the trnsitive closure? Explin your nswer. w ij = w ij (w ik w kj ) It computes the pth ij y connecting pths ik nd kj going throug k. () (3 points) Give W 0 = M R for the reltion {(, ), (, ), (, c)} W 0 = M R = c 0 0 0 (c) (6 points) Bsed on the ordering of the nodes s,, c give the mtrices W through W 3 s produced y the Wrshll s lgorithm. W = c 0 W 2 = c

W 3 = c (d) (3 points) Give the run time complexity of the Wrshll s lgorithm. O(n 3 ) 2. ollowing reltion is defined on the set A = {5, 20, 29, 27} R = {(, )ɛa A (mod 3)} () (5 points) Give the reltion R s set. {(5, 5), (20, 20), (29, 29), (27, 27), (5, 27), (27, 5), (20, 29), (29, 20)} R: 5 27 20 29 () (3 points) Why R is n equivlence reltion? rom the ove reltion it is seen tht R is reflexive, symmetric nd trnsitive. (c) (5) Give the equivlence clsses for the reltion R. [5] = {5, 27} [20] = {20, 29} 3. ollowing is reltionl tle contining person nmes nd their telephone numers. A person cn hve more thn one telephone numer nd telephone numer my elong to more thn one person. P nme tel ------------------ n t n2 t n2 t2 n3 t3 () (3 points) Write the ove reltionl tle in set nottion. {(n, t), (n2, t), (n2, t2), (n3, t3)} () Provide mening of ech of the following queries in simple English. Give the results of the queries in set nottion. i. (3 points) {x y P (x, y) z (x z P (z, y)} Nmes of those with tel not shred y nyone else. {n3} 2

ii. (3 points) Give set uilder nottion for the following query: Give nmes of those persons whose telephone numer is not t. {x.nme P (x) y ((P (y) y.tel = t ) y.nme x.nme)} Explntion: hose y s who hve tel. ti nd x s nme is not sme s ny one of those y s. iii. (5 points) Give n SQL sttement for the following query using SQL EXISS. Get the nmes of those persons who shres telephone numer with nother person. SELEC X.nme ROM P X WHERE EXISS SELEC * ROM P Y WHERE X.tel=Y.tel nd X.nme!= Y.nme!= represents not equl 4. Let V = {S, A, B,,, c} nd = {,, c}. Determine whether G =< V,, S, P > is type 0 grmmr ut not type grmmr, type grmmr ut not type 2 grmmr, or type 2 grmmr ut not type 3 grmmr, or type 3 grmmr if P, the set of productions, is () (3 points) S S S S ype 2 ut not type 3 () (3 points) S AB B A A A c ype 2 ut not type 3 5. Give the lnguges, using set uilder nottion, for the following two grmmrs. () (3 points) G :< V,, S, P > V = {S, A, B,,, c} = {,, c} P={S AB, A A c, B B c} L(G) = { i c j c i 0 j 0} () (3 points) G :< V,, S, P > V = {S,,, c} = {,, c} P={S SB c, B B λ} L(G) = { i c( j ) i i 0, j 0} OR { i c j i, j 0} 3

6. Consider the following grmmr for rithmetic expressions: G: V = {E,,, +,, (, ),,, c}, = {+,, (, ),,, c}, P = {E E +, E,,, (E),,, c} () (5 points) Give derivtion for the word ((+)*c)+. E E + E + E + + + (E)+ (E )+ (E ) + (E c) + ( c) + ( c) + ((E) c) + ((E + ) c)+ ((E + ) c)+ ((E +) c)+ (( +) c)+ (( + ) c) + ( + ) c) + () (5 points) Construct the prse tree for the word ((+)*c)+. E + ( c E E * ( ) E + ) (c) (3 points) Extend the grmmr G to include the opertors - (minus) nd / (division). G extended : V = {E,,, +,,, /, (, ),,, c}, = {+,,, /, (, ),,, c}, P = {E E +, E E, E,, /,, (E),,, c} 7. (5 points) Construct finite-stte mchine for the lnguge: 0 0 E s 0 0 s 0 0, s 2 Reject NOE: Becuse trnsitions re functionl mpping (trnsition function), trnsitions hve to e defined for ll vlues of the domin (QxI). A must e le to go to the end of the input string for ny given input string to decide whether to ccept or reject the input string. 8. () (4 points) Give n A for the following lnguge: {x x = i i, i 2} 4

s0 s2 s s5, s3, s4, s6 () (6 points) Give two strings (words) for the following lnguge nd indicte why n A cnnot e uilt for the lnguge? {x x = i i, i 0}, 2 2 As cn e seen from the ove construction, to hndle string i i for ritrry vlue of i, one needs to hve n infinite numer of sttes which is not finite stte mchine. his not proof y ny mens ut n intuitive justifiction. his indictes tht context free lnguges (which re not regulr) cnnot e recognized y n A. 9. rnsition function of n A is defined s follows: f : S I S where S is finite set of sttes nd I is finite input lphet. () (2 points) Why for ech stte in n A trnsition hs to e defined for every input chrcter? Becuse it is function. () (2 points) Define the domin nd codomin of n NA where S is finite set of sttes nd I is finite input lphet. Domin is S Codomin is 2 S (c) (2 points) Why in NA trnsition function need not e defined for ech input on stte. In n NA trnsition on n input is to set of sttes which is suset of 2 S. Becuse 2 S includes the null set trnsition does not hve to go to ny stte. 0. Consider the nondeterministic finite stte mchine given elow (Mchine M): 0, 0, s0 s () (5 points) Wht is L(M) {0, } {0, } () (8 points) Convert the ove NA to n A y using n lgorithmic process. Descrie riefly your steps. q ɛq A, ɛi, f A (q, ) = pɛqn A f N A (p, ) 5

0 s0 s0,s 0, 6