CS 44 Exam #2 February 14, 2001

Similar documents
CSC-461 Exam #2 April 16, 2014

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

(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

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

Theory Bridge Exam Example Questions Version of June 6, 2008

Theory of Computation Dr. Weiss Extra Practice Exam Solutions

Multiple Choice Questions

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

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2016

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

The Turing Machine. Unsolvable Problems. Undecidability. The Church-Turing Thesis (1936) Decision Problem. Decision Problems

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

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

Derivations of a CFG. MACM 300 Formal Languages and Automata. Context-free Grammars. Derivations and parse trees


UNIT I PART A PART B

Decision Properties for Context-free Languages

Midterm I (Solutions) CS164, Spring 2002

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

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

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

Turing Machine Languages

1 Parsing (25 pts, 5 each)

QUESTION BANK. Unit 1. Introduction to Finite Automata

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

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

JNTUWORLD. Code No: R

CS210 THEORY OF COMPUTATION QUESTION BANK PART -A UNIT- I

TAFL 1 (ECS-403) Unit- V. 5.1 Turing Machine. 5.2 TM as computer of Integer Function

Specifying Syntax COMP360

CS103 Handout 16 Winter February 15, 2013 Problem Set 6

CT32 COMPUTER NETWORKS DEC 2015

Final Exam 1, CS154. April 21, 2010

CpSc 421 Final Solutions

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

Context-Free Grammars

Theory of Computation, Homework 3 Sample Solution

Outline. Language Hierarchy

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

Enumerations and Turing Machines

Formal Grammars and Abstract Machines. Sahar Al Seesi

DHANALAKSHMI SRINIVASAN INSTITUTE OF RESEARCH AND TECHNOLOGY SIRUVACHUR, PERAMBALUR DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Theory of Computations Spring 2016 Practice Final Exam Solutions

14.1 Encoding for different models of computation

Introduction to Automata Theory. BİL405 - Automata Theory and Formal Languages 1

Models of Computation II: Grammars and Pushdown Automata

Context Free Languages and Pushdown Automata

CS143 Midterm Fall 2008

We can create PDAs with multiple stacks. At each step we look at the current state, the current input symbol, and the top of each stack.

SWEN 224 Formal Foundations of Programming

YOUR NAME PLEASE: *** SOLUTIONS ***

CS 2210 Sample Midterm. 1. Determine if each of the following claims is true (T) or false (F).

Normal Forms for CFG s. Eliminating Useless Variables Removing Epsilon Removing Unit Productions Chomsky Normal Form

LR Parsing. The first L means the input string is processed from left to right.

Equivalence of NTMs and TMs

LL(1) predictive parsing

ECS 120 Lesson 16 Turing Machines, Pt. 2

University of Technology Department of Computer Sciences. Final Examination st Term. Subject:Compilers Design

CS21 Decidability and Tractability

Recursively Enumerable Languages, Turing Machines, and Decidability

CSE 5317 Midterm Examination 4 March Solutions

Turing Machines, continued

Post's Correspondence Problem. An undecidable, but RE, problem that. appears not to have anything to do with. TM's.

Complementing Non-CFLs If A and B are context free languages then: AR is a context-free language TRUE

Final Course Review. Reading: Chapters 1-9

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

CSCE 531 Spring 2009 Final Exam

Context-Free Grammars

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

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

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

AUBER (Models of Computation, Languages and Automata) EXERCISES

LL(1) predictive parsing

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

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

Lec-5-HW-1, TM basics

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

Final Exam 2, CS154. April 25, 2010

Actually talking about Turing machines this time

Introduction to Syntax Analysis. The Second Phase of Front-End

ONE-STACK AUTOMATA AS ACCEPTORS OF CONTEXT-FREE LANGUAGES *

Lecture Bottom-Up Parsing

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

COMP 330 Autumn 2018 McGill University

Introduction to Syntax Analysis

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

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

Computer Sciences Department

Parsing. For a given CFG G, parsing a string w is to check if w L(G) and, if it is, to find a sequence of production rules which derive w.

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

Chapter 14: Pushdown Automata

CS311 / MATH352 - AUTOMATA AND COMPLEXITY THEORY

CSE 105 THEORY OF COMPUTATION

(a) (4 pts) Prove that if a and b are rational, then ab is rational. Since a and b are rational they can be written as the ratio of integers a 1

Compiler Construction

BSCS Fall Mid Term Examination December 2012

COL728 Minor1 Exam Compiler Design Sem II, Answer all 5 questions Max. Marks: 20

Theory of Computations Spring 2016 Practice Final

Defining syntax using CFGs

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

Transcription:

CS 44 Exam #2 February 14, 2001 Name Time Started: Time Finished: Each question is equally weighted. You may omit two questions, but you must answer #8, and you can only omit one of #6 or #7. Circle the questions you are omitting. (Do not just leave them blank.) Show your work and state your assumptions for partial credit consideration. Unless explicitly stated, there are NO intended errors and NO trick questions. If in doubt, ask! You have two hours to work. 1. Answer each of the following questions with a brief paragraph. [5 points each] (a) Why is the concept of a Turing Machine important? Mention the Church- Turing Hypothesis in your answer. (b) Prove that the following grammar is ambiguous: S 0 S0 1SS SS1 S1S (c) We proved that regular languages are closed under intersection by defining a procedure for constructing a machine to recognize the strings in both languages. Briefly explain what goes wrong when we try to combine two DPDAs in the same way to get a machine for the intersection of two DCFLs. (d) Suppose Turing Machine T moves its tape head right on every move. What can you say about L(T)? Explain your answer.

2. Give CFGs to generate the following languages, and show a derivation of the string x in each case. [10 points each] (a) L = {a i b j c k i = k or j = k}, x = aabcc (b) (00 + 11)*, x = 001111 3. (a) Construct a deterministic PDA for the following language. You must also give a brief, informal English description of how the machine works. [15 points] L = {a m ba m m 0} {a k ca 2k k 0}

(b) Give a convincing argument (not necessarily a formal proof) of the fact that the deterministic CFLs are a proper subset of the CFLs. [5 points] 4. Give precise algorithms for the following decision problems. If appropriate, explain how we know when we can stop the algorithm. (a) Given a regular expression r, is the language described by r empty? [5 points] (b) Given a CFL L and string x, is x L? (Do not give an answer involving PDAs.) [5 points] (c) Given regular languages L 1 and L 2, is L 1 a proper subset of L 2? [10 points]

5. Consider the following context-free grammar G: S S 1 $ S 1 S 1 A A a ab (a) Find an equivalent LL(1) grammar by factoring and eliminating left recursion. [8 points] (b) Construct a top-down parser for L(G). Show the transition table and any other necessary information. [8 points] (c) Trace the steps of the parser on the input string aba$, showing at each step the state, unread input and stack contents. Explain the important steps. You may stop once it is clear how the parsing process works. [4 points]

6. Consider the following CFG: S asa bsb a b (a) Describe the language that is generated by the CFG. [5 points] (b) Prove your answer. [15 points] 7. Recall from our class discussion that the language L = {a n b n c n n 0} is not context free. Draw a transition diagram for a Turing Machine accepting L. Do not use any TM subroutines.

8. (a) Draw a transition diagram for a TM which computes the delete function, converting configuration (q, xcy) to (h, xy), where c {0,1, } and x,y {0,1}*. Do not use any TM subroutines in your answer. [8 points] (b) Draw a transition diagram for a TM which sums a list of positive integers. The initial configuration for the machine is (q 0, n a 1... a n ),where n is an integer specifying how many numbers are to be added, and a 1 -a n are the numbers themselves. The final configuration of the machine should be (h, a 1 +...+a n ). All values are represented as sequences of 1 s. For example, started with (q 0, 111 1111 111 1 ) your machine should produce (q 0, 11111111 ). That is, 4 + 3 + 1 = 8. You may use the delete machine from part a, but no other subroutine. [12 points] Enjoy your day off on Friday!