CS375 Midterm Exam Solution Set (Fall 2017)

Similar documents
Chapter 6. Properties of Regular Languages

Exam 1 CSU 390 Theory of Computation Fall 2007

CS375: Logic and Theory of Computing

1. (a) Explain the procedure to convert Context Free Grammar to Push Down Automata.

Solution to CS375 Homework Assignment 11 (40 points) Due date: 4/26/2017

Formal Languages, Automata and Models of Computation

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

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

CSE 311: Foundations of Computing. Lecture 23: Finite State Machine Minimization & NFAs

Sri vidya college of engineering and technology

CS 154 Formal Languages and Computability Assignment #2 Solutions

False. They are the same language.

Closure under the Regular Operations

St.MARTIN S ENGINEERING COLLEGE Dhulapally, Secunderabad

Author: Vivek Kulkarni ( )

CS A Term 2009: Foundations of Computer Science. Homework 2. By Li Feng, Shweta Srivastava, and Carolina Ruiz.

September 11, Second Part of Regular Expressions Equivalence with Finite Aut

AC68 FINITE AUTOMATA & FORMULA LANGUAGES JUNE 2014

1 Alphabets and Languages

Chapter 5. Finite Automata

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

Homework 4. Chapter 7. CS A Term 2009: Foundations of Computer Science. By Li Feng, Shweta Srivastava, and Carolina Ruiz

Author: Vivek Kulkarni ( )

CMSC 330: Organization of Programming Languages

CSCE 551 Final Exam, Spring 2004 Answer Key

Lecture 4: More on Regexps, Non-Regular Languages

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Finite Automata Theory and Formal Languages TMV026/TMV027/DIT321 Responsible: Ana Bove

Theory of Computation

Homework 02 Solution updated

Nondeterminism. September 7, Nondeterminism

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

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

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

TDDD65 Introduction to the Theory of Computation

VTU QUESTION BANK. Unit 1. Introduction to Finite Automata. 1. Obtain DFAs to accept strings of a s and b s having exactly one a.

Computational Models - Lecture 4

GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I

Warshall s algorithm

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

Question Bank UNIT I

Automata: a short introduction

Theory of Computation (II) Yijia Chen Fudan University

Recap DFA,NFA, DTM. Slides by Prof. Debasis Mitra, FIT.

Computer Sciences Department

Nonregular Languages

What we have done so far

Theory of Computation Lecture 1. Dr. Nahla Belal

Theory of Computation (Classroom Practice Booklet Solutions)

More Properties of Regular Languages

Concatenation. The concatenation of two languages L 1 and L 2

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

(b) If G=({S}, {a}, {S SS}, S) find the language generated by G. [8+8] 2. Convert the following grammar to Greibach Normal Form G = ({A1, A2, A3},

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

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

Properties of Context-Free Languages

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

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

Languages, regular languages, finite automata

Lecture 17: Language Recognition

Formal Languages and Automata

CS 275 Automata and Formal Language Theory

Finite Automata. Finite Automata

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

Name: Student ID: Instructions:

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

This lecture covers Chapter 7 of HMU: Properties of CFLs

CS 154, Lecture 3: DFA NFA, Regular Expressions

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

10. The GNFA method is used to show that

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

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

Examples of Regular Expressions. Finite Automata vs. Regular Expressions. Example of Using flex. Application

Pushdown Automata. We have seen examples of context-free languages that are not regular, and hence can not be recognized by finite automata.

Proving languages to be nonregular

Chomsky Normal Form and TURING MACHINES. TUESDAY Feb 4

Deterministic Finite Automata (DFAs)

CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata (cont )

Solution. S ABc Ab c Bc Ac b A ABa Ba Aa a B Bbc bc.

AC68 FINITE AUTOMATA & FORMULA LANGUAGES DEC 2013

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Clarifications from last time. This Lecture. Last Lecture. CMSC 330: Organization of Programming Languages. Finite Automata.

CS 455/555: Finite automata

front pad rear pad door

CHAPTER 1 Regular Languages. Contents

Regular Expressions [1] Regular Expressions. Regular expressions can be seen as a system of notations for denoting ɛ-nfa

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

CpSc 421 Homework 1 Solutions

COM364 Automata Theory Lecture Note 2 - Nondeterminism

Solutions to Problem Set 3

CMSC 330: Organization of Programming Languages. Theory of Regular Expressions Finite Automata

Automata Theory CS F-04 Non-Determinisitic Finite Automata

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

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

Automata & languages. A primer on the Theory of Computation. Laurent Vanbever. ETH Zürich (D-ITET) October,

Part 3 out of 5. Automata & languages. A primer on the Theory of Computation. Last week, we learned about closure and equivalence of regular languages

CS 133 : Automata Theory and Computability

Computational Theory

Notes for Comp 497 (Comp 454) Week 10 4/5/05

Computational Models - Lecture 3

Transcription:

CS375 Midterm Exam Solution Set (Fall 2017) Closed book & closed notes October 17, 2017 Name sample 1. (10 points) (a) Put in the following blank the number of strings of length 5 over A={a, b, c} that begins with a and have at least one c. (6 points) 1 (3 4 2 4 ) = 65 (b) Use the pigeonhole principle to determine how many people are needed in a group to say that three were born in the same month. Put your answer in the following blank. (4 points) 25 2. Fill out the following blank with a regular expression for the language: { Ʌ, a, b, aa, bb,, a n, b n, } (4 points) a* + b* 3. Fill out the first blank with a regular expression for the language over the alphabet {a, b} with no string containing the substring bbb, then fill out the second blank with a regular expression for the language over the same alphabet with no string containing the substring bbbb. (6 points ) (a + ba + bba)*(ʌ + b + bb) (a + ba + bba + bbba)*(ʌ + b + bb + bbb) 4. Fill out the following blanks to make it a DFA for the expression: a*bc* + aaac + aac + ac ( 10 points )

5. To get an NFA for the given regular expression: (a + b)b*, the initial step is to put (a + b)b* as the label of an edge between a start state and a final state, as follows. (a + b)b* We then apply R.S to get the following graph. Fill out the blanks in the following graph (2 points) a+b b* The next step is to expand the labels of both edges in the above graph to get the following NFA. Fill out the blanks in the following graph. (4 points) a Ʌ Ʌ b b This is an NFA for the given regular expression. 6. To transform the following NFA into a regular expression,

we first connect a new start state s to the start state of the given NFA and connect each final state of the given NFA to a new final state f as shown below. We then eliminate the states of the given NFA until only state s and state f are left. If we eliminate state 1 first, we would get the following NFA. Fill out the blanks in the following NFA. (4 points) If we then eliminate state 2, we would get the following NFA. Fill out the blanks in this NFA. (4 points) Finally, we eliminate state 0 to get the following NFA. The label of the edge between state s and state f is the regular expression of the given NFA. What is it? (2 point)

7. Given the following NFA over the alphabet {a, b}, to transform the given NFA to a DFA, first construct Ʌ-closures of all the states of the given NFA. Fill out the blanks for state 0 and state 1. (2 points) {0,1,2} {1,2} Next to get the states of the DFA, we construct a tree as follows. Fill out the blanks in the following tree. (6 points) The distinct nodes in the above binary tree are the states of the DFA to be constructed. 8. Given the following DFA, to find a minimum-state DFA, (10 points) we first construct E0

Then construct E1. Out of the following four cases (a), (b), (c) and (d), which one represents the correct E1? Put your answer in the following blank. The correct E1 is: c 9. Fill out the blanks of the following grammar to make it a regular grammar for the given regular expression where S is the start symbol: ab* + c (10 points)

10. To find a regular grammar for the expression a*b + bb + c, we can also transform it into an equivalent NFA as follows first, construct all the Ʌ-closures, build the following tree (fill out the blank in the tree), (2 points) identify the distinct nodes of the tree (fill out the blank in the list), (2 points) construct the following transition table (fill out the blanks in the table), (4 points)

write in simplified form after renumbering the states build the corresponding DFA after removing the don t need portion and renaming, we get a DFA on the right hand side. rename

The regular grammar for this DFA is the one on the left below (fill out the two blanks there). After replacing each C with Ʌ, we get the regular grammar on the right hand side (fill out the two blanks there): (4 points) If we further replace the B in the first line with b and Ʌ respectively, we get the grammar on the left below (fill out the red blanks). Since the portion that is inside the blue box in the first line is the same as the items inside the blue box in the second line, we can replace the items inside the blue box of the first line with A to get the grammar on the right side. This is regular grammar of the expression a*b + bb + c. (4 points) 11. An NFA that can recognize the language of the following regular grammar: S as bs ai, I bj a, J bk a, K Ʌ can be constructed as follows. Fill out the blanks in the following NFA. (5 points) 12. Pumping Lemma cannot be used for languages that are finite. Why? Which of the following three answers is correct? Put your selection in the following blank. (5 points) (a) A finite language cannot be recognized by a DFA or an NFA. (b) A finite language cannot absorb all the distinct strings that can be accepted by a DFA or an NFA. (c) A finite language does not have a regular grammar.

Ans: b