CS 181 B&C EXAM #1 NAME. You have 90 minutes to complete this exam. You may assume without proof any statement proved in class.

Similar documents
CS 181 EXAM #1 NAME. You have 90 minutes to complete this exam. You may state without proof any fact taught in class or assigned as homework.

1. (10 points) Draw the state diagram of the DFA that recognizes the language over Σ = {0, 1}

Midterm Exam II CIS 341: Foundations of Computer Science II Spring 2006, day section Prof. Marvin K. Nakayama

6 NFA and Regular Expressions

CSE 105 THEORY OF COMPUTATION

Theory of Computation Dr. Weiss Extra Practice Exam Solutions

Last lecture CMSC330. This lecture. Finite Automata: States. Finite Automata. Implementing Regular Expressions. Languages. Regular expressions

14.1 Encoding for different models of computation

NFAs and Myhill-Nerode. CS154 Chris Pollett Feb. 22, 2006.

I have read and understand all of the instructions below, and I will obey the Academic Honor Code.

HKN CS 374 Midterm 1 Review. Tim Klem Noah Mathes Mahir Morshed

Context Free Grammars. CS154 Chris Pollett Mar 1, 2006.

lec3:nondeterministic finite state automata

CSE 105 THEORY OF COMPUTATION

CS/ECE 374 Fall Homework 1. Due Tuesday, September 6, 2016 at 8pm

CSE 105 THEORY OF COMPUTATION

CS154 Midterm Examination. May 4, 2010, 2:15-3:30PM

Regular Languages and Regular Expressions

Front End: Lexical Analysis. The Structure of a Compiler

Theory of Computations Spring 2016 Practice Final Exam Solutions

Midterm I (Solutions) CS164, Spring 2002

CS 310: State Transition Diagrams

ECS 120 Lesson 16 Turing Machines, Pt. 2

Homework 1 Due Tuesday, January 30, 2018 at 8pm

CS 125 Section #10 Midterm 2 Review 11/5/14

Finite Automata Part Three

Closure Properties of CFLs; Introducing TMs. CS154 Chris Pollett Apr 9, 2007.

Automating Construction of Lexers

CSE 105 THEORY OF COMPUTATION

DVA337 HT17 - LECTURE 4. Languages and regular expressions

CS103 Handout 42 Spring 2017 May 31, 2017 Practice Final Exam 1

CMPSCI 250: Introduction to Computation. Lecture 20: Deterministic and Nondeterministic Finite Automata David Mix Barrington 16 April 2013

CS402 Theory of Automata Solved Subjective From Midterm Papers. MIDTERM SPRING 2012 CS402 Theory of Automata

CS 441 Discrete Mathematics for CS Lecture 24. Relations IV. CS 441 Discrete mathematics for CS. Equivalence relation

Finite automata. We have looked at using Lex to build a scanner on the basis of regular expressions.

CSE 105 THEORY OF COMPUTATION

COMP-421 Compiler Design. Presented by Dr Ioanna Dionysiou

t!1; R 0! 1; R q HALT

Finite Automata. Dr. Nadeem Akhtar. Assistant Professor Department of Computer Science & IT The Islamia University of Bahawalpur

MIT Specifying Languages with Regular Expressions and Context-Free Grammars

CSE 105 THEORY OF COMPUTATION

COMP 330 Autumn 2018 McGill University

University of Waterloo Midterm Examination

Theory Bridge Exam Example Questions Version of June 6, 2008

Theory of Computations Spring 2016 Practice Final

CS 432 Fall Mike Lam, Professor. Finite Automata Conversions and Lexing

JNTUWORLD. Code No: R


CSE450. Translation of Programming Languages. Lecture 20: Automata and Regular Expressions

Lexical Analysis. Implementation: Finite Automata

Implementation of Lexical Analysis

Definition 2.8: A CFG is in Chomsky normal form if every rule. only appear on the left-hand side, we allow the rule S ǫ.

Implementation of Lexical Analysis

CSE 431S Scanning. Washington University Spring 2013

CS2 Language Processing note 3

Converting a DFA to a Regular Expression JP

Multiple Choice Questions

CSCE 5400 ASSIGNMENT #1 SOLUTION

MIT Specifying Languages with Regular Expressions and Context-Free Grammars. Martin Rinard Massachusetts Institute of Technology

Lexical Analysis. Prof. James L. Frankel Harvard University

Lecture 2 Finite Automata

Limits of Computation p.1/?? Limits of Computation p.2/??

Variants of Turing Machines

Ambiguous Grammars and Compactification

Proof Techniques Alphabets, Strings, and Languages. Foundations of Computer Science Theory

Chapter Seven: Regular Expressions

Implementation of Lexical Analysis

Finite Automata Part Three

Midterm I - Solution CS164, Spring 2014

Answer All Questions. All Questions Carry Equal Marks. Time: 20 Min. Marks: 10.

CS103 Handout 13 Fall 2012 May 4, 2012 Problem Set 5

Final Course Review. Reading: Chapters 1-9

Non-context-Free Languages. CS215, Lecture 5 c

CS6160 Theory of Computation Problem Set 2 Department of Computer Science, University of Virginia

Relational Database: The Relational Data Model; Operations on Database Relations

QUESTION BANK. Unit 1. Introduction to Finite Automata

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2016

Lexical Analysis - 2

1. [5 points each] True or False. If the question is currently open, write O or Open.

CS 361 Meeting 8 9/24/18

9.5 Equivalence Relations

CS314: FORMAL LANGUAGES AND AUTOMATA THEORY L. NADA ALZABEN. Lecture 1: Introduction

Qualifying Exam Theory

Computer Sciences Department

Yet More CFLs; Turing Machines. CS154 Chris Pollett Mar 8, 2006.

Formal Languages and Automata

Lexical Analysis. Lecture 2-4

Actually talking about Turing machines this time

Outline. Language Hierarchy

Theory of Computation

Learn Smart and Grow with world

Name: Finite Automata

TOPIC PAGE NO. UNIT-I FINITE AUTOMATA

Skyup's Media. PART-B 2) Construct a Mealy machine which is equivalent to the Moore machine given in table.

1. Which of the following regular expressions over {0, 1} denotes the set of all strings not containing 100 as a sub-string?

Regular Expression Constrained Sequence Alignment

Lexical Analysis. Chapter 2

Non-deterministic Finite Automata (NFA)

CS103 Handout 14 Winter February 8, 2013 Problem Set 5

CS154. Streaming Algorithms and Communication Complexity

Transcription:

CS 8 B&C EXAM # NAME SPRING 204 UCLA ID You have 90 minutes to complete this exam. You may assume without proof any statement proved in class. Give a simple verbal description of the language recognized by the following DFA. 0 0 0 0 0 2 Draw NFAs for the following languages, taking full advantage of nondeterminism: a. strings over alphabet f0; ; : : : ; 9g where the final digit has not appeared before; b. binary strings that begin or end with 00 or.

3 Prove that the following languages over the binary alphabet are regular: a. strings in which every is immediately followed by 00; b. strings that contain both 00 and 0 as substrings; c. strings that end with 00.

4 Let L and L 2 be languages that can be recognized by NFAs with n and n 2 states, respectively. Prove that L \ L 2 can be recognized by a DFA with at most 2 n Cn 2 states. 5 Prove that every language L f0; g can be expressed as a countable union L D S for some regular languages R ;R 2 ;R 3 ;:::. id R i

6 For a language L, define delete.l/ Dfuv W u v 2 L for some 2 g: Thus, delete.l/ is the set of all strings obtained by taking a nonempty string in L and deleting a single character from it. Prove that if L is regular, so is delete.l/. 7 For a language L; define suffix.l/ Dfv W uv 2 L for some ug: Thus, suffix.l/ is the set of all suffixes of strings in L. Show how to transform a DFA for any given regular language L into an NFA for suffix.l/:

SOLUTIONS

CS 8 B&C EXAM # NAME SPRING 204 UCLA ID You have 90 minutes to complete this exam. You may assume without proof any statement proved in class. Give a simple verbal description of the language recognized by the following DFA. 0 0 0 0 0 Solution. All binary strings that end with 000. 2 Draw NFAs for the following languages, taking full advantage of nondeterminism: a. strings over alphabet f0; ; : : : ; 9g where the final digit has not appeared before; b. binary strings that begin or end with 00 or. Solution. a. b.

3 Prove that the following languages over the binary alphabet are regular: a. strings in which every is immediately followed by 00; b. strings that contain both 00 and 0 as substrings; c. strings that end with 00. Solution. a. The language is recognized by the following NFA: b. The language of strings containing 00 is recognized by Analogously, the language of strings containing 0 is recognized by Since regular languages are closed under intersection, the language in the problem statement is regular. c. The language is recognized by the following NFA: New Section Page 2 New Section Page 2 New Section Page 2 New Section Page 2

4 Let L and L 2 be languages that can be recognized by NFAs with n and n 2 states, respectively. Prove that L \ L 2 can be recognized by a DFA with at most 2 n Cn 2 states. Solution. Using the method discussed in class, transform the NFAs for L and L 2 to DFAs with at most 2 n and 2 n 2 states, respectively. Then combine these DFAs to obtain a DFA for L \L 2 with at most 2 n 2 n 2 D 2 n Cn 2 states, using the Cartesian-product construction from class. 5 Prove that every language L f0; g can be expressed as a countable union L D S for some regular languages R ;R 2 ;R 3 ;:::. id R i Solution. For any string w 2f0; g ; the language fwg is regular because it is recognized by the NFA Now define R i to be the language whose only string is the ith string in L, in lexicographic order (with the understanding that R i D if L has fewer than i strings). Then where each R i is regular by above. L D [ R i ; id

6 For a language L, define delete.l/ Dfuv W u v 2 L for some 2 g: Thus, delete.l/ is the set of all strings obtained by taking a nonempty string in L and deleting a single character from it. Prove that if L is regular, so is delete.l/. Solution: DFA for L NFA for delete(l) q! same as original DFA, but make all states reject ε add this arrow for every q and σ δ(q, σ)! same as original DFA 7 For a language L; define suffix.l/ Dfv W uv 2 L for some ug: Thus, suffix.l/ is the set of all suffixes of strings in L. Show how to transform a DFA for any given regular language L into an NFA for suffix.l/: Solution. Add "-transitions from the initial state q 0 to every state reachable from q 0.