Sample Midterm. Understanding the questions is part of the exam; you are not allowed to ask questions during the exam.

Similar documents
Theory Bridge Exam Example Questions

Name: Student ID: Instructions:

Exam 1 CSU 390 Theory of Computation Fall 2007

TDDD65 Introduction to the Theory of Computation

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

Theory of Computation

False. They are the same language.

CSCE 551 Final Exam, Spring 2004 Answer Key

2.1 Solution. E T F a. E E + T T + T F + T a + T a + F a + a

CS375 Midterm Exam Solution Set (Fall 2017)

Languages, regular languages, finite automata

PS2 - Comments. University of Virginia - cs3102: Theory of Computation Spring 2010

CISC 4090: Theory of Computation Chapter 1 Regular Languages. Section 1.1: Finite Automata. What is a computer? Finite automata

10. The GNFA method is used to show that

More Properties of Regular Languages

CSE 105 THEORY OF COMPUTATION

Computational Models - Lecture 3 1

ECS 120: Theory of Computation UC Davis Phillip Rogaway February 16, Midterm Exam

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

CSE 105 THEORY OF COMPUTATION

What we have done so far

Answers to the CSCE 551 Final Exam, April 30, 2008

Intro to Theory of Computation

Midterm Exam 2 CS 341: Foundations of Computer Science II Fall 2018, face-to-face day section Prof. Marvin K. Nakayama

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class

Formal Languages, Automata and Models of Computation

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Section 1.3 Ordered Structures

CSE 105 THEORY OF COMPUTATION

CS154 Final Examination

CSci 311, Models of Computation Chapter 4 Properties of Regular Languages

Context-Free Languages (Pre Lecture)

CS5371 Theory of Computation. Lecture 5: Automata Theory III (Non-regular Language, Pumping Lemma, Regular Expression)

Computer Sciences Department

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

Student#: CISC-462 Exam, December XY, 2017 Page 1 of 12

CS 154. Finite Automata vs Regular Expressions, Non-Regular Languages

CPSC 421: Tutorial #1

Automata: a short introduction

Lecture 7 Properties of regular languages

CSE 105 THEORY OF COMPUTATION

Chapter 2 The Pumping Lemma

CMSC 330: Organization of Programming Languages

Computational Models - Lecture 4

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

Theory of Computation p.1/?? Theory of Computation p.2/?? Unknown: Implicitly a Boolean variable: true if a word is

Unit 6. Non Regular Languages The Pumping Lemma. Reading: Sipser, chapter 1

Closure Properties of Regular Languages. Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism

Johns Hopkins Math Tournament Proof Round: Automata

CS154 Final Examination

ECS120 Fall Discussion Notes. October 25, The midterm is on Thursday, November 2nd during class. (That is next week!)

Computational Models - Lecture 3 1

CpSc 421 Final Exam December 15, 2006

Author: Vivek Kulkarni ( )

Before we show how languages can be proven not regular, first, how would we show a language is regular?

Finite Automata and Regular languages

Lecture 4: More on Regexps, Non-Regular Languages

We define the multi-step transition function T : S Σ S as follows. 1. For any s S, T (s,λ) = s. 2. For any s S, x Σ and a Σ,

Computational Theory

Context Free Languages. Automata Theory and Formal Grammars: Lecture 6. Languages That Are Not Regular. Non-Regular Languages

Context-Free Languages

V Honors Theory of Computation

CS154. Non-Regular Languages, Minimizing DFAs

CS 154, Lecture 4: Limitations on DFAs (I), Pumping Lemma, Minimizing DFAs

Problem 2.6(d) [4 pts] Problem 2.12 [3pts] Original CFG:

Closure Properties of Context-Free Languages. Foundations of Computer Science Theory

Midterm Exam 2 CS 341: Foundations of Computer Science II Fall 2016, face-to-face day section Prof. Marvin K. Nakayama

CS 530: Theory of Computation Based on Sipser (second edition): Notes on regular languages(version 1.1)

CSE 105 THEORY OF COMPUTATION

(Refer Slide Time: 0:21)

Closure under the Regular Operations

Notes for Comp 497 (Comp 454) Week 5 2/22/05. Today we will look at some of the rest of the material in Part 1 of the book.

Please give details of your calculation. A direct answer without explanation is not counted.

Automata Theory Final Exam Solution 08:10-10:00 am Friday, June 13, 2008

Chap. 4,5 Review. Algorithms created in proofs from prior chapters

Proving languages to be nonregular

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

CS 154, Lecture 3: DFA NFA, Regular Expressions

Comment: The induction is always on some parameter, and the basis case is always an integer or set of integers.

CSE 105 Theory of Computation Professor Jeanne Ferrante

Let P(n) be a statement about a non-negative integer n. Then the principle of mathematical induction is that P(n) follows from

CSE 311: Foundations of Computing I Autumn 2014 Practice Final: Section X. Closed book, closed notes, no cell phones, no calculators.

Grade 6 Math Circles October 20/21, Formalism and Languages: Beyond Regular Languages

Computational Models - Lecture 3

1. Provide two valid strings in the languages described by each of the following regular expressions, with alphabet Σ = {0,1,2}.

acs-04: Regular Languages Regular Languages Andreas Karwath & Malte Helmert Informatik Theorie II (A) WS2009/10

Properties of Regular Languages. Wen-Guey Tzeng Department of Computer Science National Chiao Tung University

CSCE 551 Final Exam, April 28, 2016 Answer Key

Chapter 2: Finite Automata

Section 1 (closed-book) Total points 30

3515ICT: Theory of Computation. Regular languages

Finite Automata and Regular Languages

Final Exam Comments. UVa - cs302: Theory of Computation Spring < Total

Before We Start. The Pumping Lemma. Languages. Context Free Languages. Plan for today. Now our picture looks like. Any questions?

1 Functions, relations, and infinite cardinality

1 Functions, relations, and infinite cardinality

Languages. Non deterministic finite automata with ε transitions. First there was the DFA. Finite Automata. Non-Deterministic Finite Automata (NFA)

Solutions to Old Final Exams (For Fall 2007)

Lecture Notes On THEORY OF COMPUTATION MODULE -1 UNIT - 2

CSE 105 THEORY OF COMPUTATION

Transcription:

Sample Midterm Name: This exam consists of five questions. Each question is worth 10 points. The exam is worth 40 points. Your exam score is the sum of your four highest question scores. Calculators, cell phones, PDAs, etc. are not allowed. Use only scrap paper provided by me. Understanding the questions is part of the exam; you are not allowed to ask questions during the exam. As usual, you only have to explain your answer if this is stated in the question. You may only leave the room after you are done with the exam. Note: This midterm was adapted from a midterm that used a different book. It has not been proofread as well as your midterm will be. 1

1. Let Σ = {0,1}. In this question, every string over Σ is viewed as a binary natural number. Leading 0s are allowed. For example, 00100 is viewed as the number 4. ǫ is viewed as the number 0. Look at the following list of six languages. L 1 = {x Σ x 16}. L 2 = {x Σ x is a square and x < 1000}. L 3 = {x Σ x is not divisible by 3}. L 4 = {x Σ x is divisible by 666}. L 5 = {xy x,y Σ and x y = 12}. L 6 = {xy x,y Σ, x = y, and x and y represent the same number}. (a) Which of the languages from the list are regular? L 1, L 2, L 3, L 4, and L 5. (b) Which of the languages from the list contain ǫ? L 2, L 4, and L 6. (c) Draw the transition diagram of a DFA that accepts one of the languages from the list or give a regular expression that represents one of the languages from the list. Also state which language you chose. Different answers are possible. You want to pick a case that is easy and that you sure about. And you should do just one case! Regular expression for L 1 : 0 1(0 + 1) (0 + 1) 4 The DFA for L 1 is also easy. L 5 is pretty easy as well. Regular expression: 0 10 1100 + 0 100 110 + 0 110 100 + 0 1000 11 + 0 1100 10 + 0 11000 1 2

2. Write an algorithm that determines if two DFAs are equivalent. Your algorithm should take as input two DFAs M 1 and M 2 and should output equivalent if L(M 1 ) = L(M 2 ) and not equivalent if they are not. You can use all constructions from the book and notes. Clearly state what you are using where. There are two approaches. (a) Minimize M 1 ; call the result M 1. Minimize M 2; call the result M 2. Then check if M 1 and M 2 are the same DFA (apart from the names of the states). (You may want to add a line or so explaining how to do this.) If M 1 and M 2 are the same DFA, output equivalent ; otherwise, output not equivalent. (We are using the fact that minimum DFAs are unique.) (b) Construct a DFA M such that L(M) is the disjoint union of L(M 1 ) and L(M 2 ). This can be done by using the Cartesian product construction on M 1 and M 2 and letting F = {(r 1,r 2 ) (r 1 F 1 ) (r 2 F 2 )}. Then check if L(M) =. This can be done by checking if no final state is reachable from the start state. Or by minimizing M and checking if the resulting DFA is the one-state DFA with no accepting states. If L(M) =, output equivalent ; otherwise, output not equivalent. 3

3. Let Σ = {a,b}. Let double be the function from Σ to Σ that doubles each character in a string. For example, double(baaba) = bbaaaabbaa. (a) What is double(aabaa)? aaaabbaaaa (b) What is double(ǫ)? ǫ (c) Suppose x {a,b} and the length of x is k. What is the length of double(x)? 2k For L a language over Σ, define double(l) as follows: double(l) = {double(x) x L}. (d) Let A be the language {ab,bbb,baba}. What is double(a)? {aabb, bbbbbb, bbaabbaa} (e) List all languages B over Σ that have the property that double(b) = B. and {ǫ} (f) For each of the following statements, circle the right answer. i. If L is a regular language over Σ, then double(l) is regular. True ii. If L is a finite language over Σ, then double(l) is finite. True iii. If L Σ is not regular, then double(l) is not regular. True iv. If L 1 and L 2 are regular languages over Σ, then L 1 L 2 is regular. True v. If L 1 and L 2 are finite languages over Σ, then L 1 L 2 is finite. True vi. If L 1 Σ and L 2 Σ are not regular, then L 1 L 2 is not regular. False (g) For one of the six questions in part (f) where you answered false, give an explicit counter example. Also clearly state which question you chose. To show that vi is false, take L 1 = {a i b i i 0} and L 2 = L 1. 4

4. Let L = {a i b k a l l > i + k}. (a) List all strings in L of length 7. a 7,ba 6,aba 5,bba 5,aaba 4,abba 4,b 3 a 4 (b) Use the Pumping Lemma for Regular Languages to prove that L is not regular. Suppose for a contradiction that L is regular. Let p be the pumping length given by the pumping lemma. Let s = b p a p+1. Then s L and s p. By the pumping lemma, s can be split into three pieces, s = xyz, such that y > 0, xy p, and xy i z L for all i 0. In particular, xy 2 z L. (Choose i = 2.) Since xy p, uv 2 w = b n+ y a p+1. Since y > 0, p+1 p+ y. It follows that xy 2 z L. This is a contradiction. It follows that the assumption that L is regular is wrong. So, we have shown that L is not regular. 5

5. This question is about the subset construction. In this question, take Σ = {a,b,c}. (a) If you literally apply the subset construction to an NFA with k states, how many states will the corresponding DFA have? 2 k (b) Give a simple example of a minimal NFA such that the DFA obtained by literally applying the subset construction is not minimal. (A minimal NFA is an NFA such that no equivalent NFA has fewer states.) For your answer, draw the transition diagram of the NFA, the transition diagram of the DFA obtained by applying the subset construction, and briefly argue that the DFA is not minimal. Consider the NFA M 1 with one rejecting state and no transitions (you need to draw the transition diagram). Clearly, M 1 is minimal, since an NFA can not have fewer than one state. L(M 1 ) = and there exists a one-state DFA that accepts. But the subset construction gives a two-state DFA (you need to draw the transition diagram). (c) Give a simple example of a minimal NFA such that the DFA obtained by literally applying the subset construction is minimal. For your answer, draw the transition diagram of the NFA, the transition diagram of the DFA obtained by applying the subset construction, and briefly argue that the DFA is minimal. Consider the NFA M 2 with one accepting state and no transitions (draw it). Clearly, M 2 is minimal, since an NFA can not have fewer than one state. L(M 2 ) = {ǫ}. The two-state DFA given by the subset construction (draw it) is minimal, since an DFA that accepts ǫ needs at least one accepting state, and an DFA that does not accept Σ needs at least one rejecting state. 6