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

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

Theory of Computation Dr. Weiss Extra Practice Exam Solutions

Theory of Computations Spring 2016 Practice Final Exam Solutions

Theory Bridge Exam Example Questions Version of June 6, 2008

CS5371 Theory of Computation. Lecture 8: Automata Theory VI (PDA, PDA = CFG)

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

R10 SET a) Construct a DFA that accepts an identifier of a C programming language. b) Differentiate between NFA and DFA?

Decidable Problems. We examine the problems for which there is an algorithm.

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

CSE 105 THEORY OF COMPUTATION

Theory of Computations Spring 2016 Practice Final

CT32 COMPUTER NETWORKS DEC 2015

CSE 105 THEORY OF COMPUTATION

Final Exam 1, CS154. April 21, 2010

QUESTION BANK. Formal Languages and Automata Theory(10CS56)

CSC-461 Exam #2 April 16, 2014

CS143 Midterm Fall 2008

Theory of Computation, Homework 3 Sample Solution

Computer Sciences Department

CS402 - Theory of Automata Glossary By

Midterm I (Solutions) CS164, Spring 2002

Final Exam 2, CS154. April 25, 2010

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

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

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

Lecture 2 Finite Automata

CpSc 421 Final Solutions

Multiple Choice Questions

JNTUWORLD. Code No: R

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

UNIT I PART A PART B

(Refer Slide Time: 0:19)

CS 44 Exam #2 February 14, 2001

(a) R=01[((10)*+111)*+0]*1 (b) ((01+10)*00)*. [8+8] 4. (a) Find the left most and right most derivations for the word abba in the grammar

Actually talking about Turing machines this time

University of Nevada, Las Vegas Computer Science 456/656 Fall 2016

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2016

T.E. (Computer Engineering) (Semester I) Examination, 2013 THEORY OF COMPUTATION (2008 Course)

Introduction to Computers & Programming

Decision Properties for Context-free Languages

Name: CS 341 Practice Final Exam. 1 a 20 b 20 c 20 d 20 e 20 f 20 g Total 207

Turing Machines. A transducer is a finite state machine (FST) whose output is a string and not just accept or reject.

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

Equivalence of NTMs and TMs

Languages and Automata

Turing Machines Part Two

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

Regular Languages (14 points) Solution: Problem 1 (6 points) Minimize the following automaton M. Show that the resulting DFA is minimal.

From Theorem 8.5, page 223, we have that the intersection of a context-free language with a regular language is context-free. Therefore, the language

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

Theory of Computation

CSE 105 THEORY OF COMPUTATION

ECS 120 Lesson 16 Turing Machines, Pt. 2

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

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 ǫ.

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.

PS3 - Comments. Describe precisely the language accepted by this nondeterministic PDA.


Turing Machine Languages

lec3:nondeterministic finite state automata

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

Finite Automata Part Three

A Characterization of the Chomsky Hierarchy by String Turing Machines

Finite Automata Part Three

Computation, Computers, and Programs. Administrivia. Resources. Course texts: Kozen: Introduction to Computability Hickey: Introduction to OCaml

CS143 Midterm Sample Solution Fall 2010

14.1 Encoding for different models of computation

Chapter Seven: Regular Expressions

Turing Machines, continued

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

Chapter 14: Pushdown Automata

CS 164 Handout 11. Midterm Examination. There are seven questions on the exam, each worth between 10 and 20 points.

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

Midterm I - Solution CS164, Spring 2014

Learn Smart and Grow with world

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

CS Lecture 2. The Front End. Lecture 2 Lexical Analysis

1. Draw the state graphs for the finite automata which accept sets of strings composed of zeros and ones which:

6 NFA and Regular Expressions

Context-Free Languages & Grammars (CFLs & CFGs) Reading: Chapter 5

CMSC 330, Fall 2018 Midterm 2

Limitations of Algorithmic Solvability In this Chapter we investigate the power of algorithms to solve problems Some can be solved algorithmically and

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

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

Problems, Languages, Machines, Computability, Complexity

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.

CISC 4090 Theory of Computation

CS103 Handout 14 Winter February 8, 2013 Problem Set 5

CSE 105 THEORY OF COMPUTATION

TOPIC PAGE NO. UNIT-I FINITE AUTOMATA

Definition: A context-free grammar (CFG) is a 4- tuple. variables = nonterminals, terminals, rules = productions,,

To illustrate what is intended the following are three write ups by students. Diagonalization

PDA s. and Formal Languages. Automata Theory CS 573. Outline of equivalence of PDA s and CFG s. (see Theorem 5.3)

Formal Languages and Automata

Automating Construction of Lexers

Outline. Language Hierarchy

Front End: Lexical Analysis. The Structure of a Compiler

Final Course Review. Reading: Chapters 1-9

UVa ID: NAME (print): CS 4501 LDI Midterm 1

1 Parsing (25 pts, 5 each)

Transcription:

Midterm Exam CS 341-451: Foundations of Computer Science II Fall 2014, elearning section Prof. Marvin K. Nakayama Print family (or last) name: Print given (or first) name: I have read and understand all of the instructions below, and I will obey the Academic Honor Code. Signature and Date This exam has 10 pages in total, numbered 1 to 10. Make sure your exam has all the pages. Unless other prior arrangements have been made with the professor, the exam is to last 2.5 hours and is to be given on Saturday, October 18, 2014, 9:30am 12:00pm. This is a closed-book, closed-note exam. No electronic devices (e.g., calculators, cellphones) are allowed. For all problems, follow these instructions: 1. Give only your answers in the spaces provided. I will only grade what you put in the answer space, and I will take off points for any scratch work in the answer space. Use the scratch-work area or the backs of the sheets to work out your answers before filling in the answer space. 2. DFA stands for deterministic finite automaton; NFA stands for nondeterministic finite automaton; CFG stands for context-free grammar; PDA stands for pushdown automaton. TM stands for Turing machine. 3. For any proofs, be sure to provide a step-by-step argument, with justifications for every step. If you are asked to prove a result X, in your proof of X, you may use any other result Y without proving Y. However, make it clear what the other result Y is that you are using; e.g., write something like, By the result that A = A, we know that... Problem 1 2 3 4 5 6 Total Points 1

1. [20 points] For each of the following, circle TRUE if the statement is correct. Otherwise, circle FALSE (a) TRUE FALSE A language L has a CFG if and only if L is recognized by a PDA. (b) TRUE FALSE If a language A is not regular, then it must be infinite. (c) TRUE FALSE If a language is infinite, then it must not be regular. (d) TRUE FALSE If A is a regular language, then A has a regular expression. (e) TRUE FALSE A regular expression for the language {0 n 1 n n 0} is 0 1. (f) TRUE FALSE If A = {01,1} and B = {ε}, then A B = A B. (g) TRUE (h) TRUE FALSE The class of regular languages is closed under complementation. FALSE If A is a context-free language, then A is recognized by an NFA. (i) TRUE FALSE If A and B are context-free languages, then so is A B. (j) TRUE FALSE If A and B are context-free languages, then so is A B. 2

2. [30 points] Define L to be the set of strings that represent numbers in a modified version of Java. The goal in this problem is to define a regular expression and an NFA for L. To precisely define L, let Σ = Σ 1 Σ 2 {.}, where Σ 1 = {0, 1, 2,..., 9} is the set of digits and Σ 2 = {+, -} is the set of signs. Then L = L 1 L 2, where L 1 is the set of all strings that are decimal integer numbers. Specifically, L 1 consists of strings that start with an optional sign, followed by one or more digits. Examples of strings in L 1 are 02, +9, and -241. L 2 is the set of all strings that are floating-point numbers that are not in exponential notation. Specifically, L 2 consists of strings that start with an optional sign, followed by zero or more digits, followed by a decimal point, and end with zero or more digits, where there must be at least one digit in the string. Examples of strings in L 2 are 13.231, -28. and.124. All strings in L 2 have exactly one decimal point. Assume that there is no limit on the number of digits in a string in L. Also, we do not allow exponential notation, nor do we allow for the suffixes L, l, F, f, D, d, at the end of numbers to denote types (long integers, floats, and doubles); these symbols are not in Σ anyways. (a) Give a regular expression for L 1. (b) Give an NFA for L 1 over the alphabet Σ. 3

(c) Give a DFA for L 1 over the alphabet Σ. Your DFA must include all transitions. (d) Give a regular expression for L 2. 4

(e) Give an NFA for L 2 over the alphabet Σ. 5

(f) Give a regular expression for L. (g) Give an NFA for L over the alphabet Σ. 6

3. [10 points] The Turing machine M below has input alphabet Σ = {b} and tape alphabet Γ = {b,x, }. b b,l x x,l x x,r,r q 5,L x x,r q 1 q 2 q 3 b,r b x,r,r x x,r,r b x,r b b,r q reject q accept q 4,R x x,r In each of the parts below, give the sequence of configurations that M enters when started on the indicated input string. (a) bb (b) bbbbb Scratch-work area 7

4. [20 points] Let Σ = {a,b,c}, and consider the language A = {a n b n c k n,k 0}. (a) Give a CFG G for A. Be sure to specify G as a 4-tuple G = (V,Σ,R,S). (b) Give a PDA for A. You only need to give the drawing. Scratch-work area 8

5. [10 points] Give an example of context-free languages A and B such that C = A B is not context-free. Explain your answer. Be sure to give CFGs for A and B. You do not have to prove that C is non-context-free for your example, but C must be a non-context-free language that we went over in the course. 9

6. [10 points] Recall the pumping lemma for regular languages: Theorem: If L is a regular language, then there is a number p (pumping length) where, if s L with s p, then s can be split into 3 pieces, s = xyz, satisfying conditions (i) xy i z L for each i 0, (ii) y > 0, and (iii) xy p. Let Σ = {a,b,c}, and consider the language A = {a n b n c k n,k 0}. Prove that A is not a regular language. 10