# AnswersH6 - INXIN for(plane = 0 1 plane for(i = 0 i<= plane i for(j = 0 j<= plane j if(i j == plane print"(i,j" Let C i denote the i

This preview shows pages 1–2. Sign up to view the full content.

University of Central Florida School of Computer Science COT 4210 Spring 2004 Prof. Rene Peralta Homework 6:answers to selected problems 1. Chapter 9, exercise 1 (Sudkamp text). 2. Consider the following grammar over Σ = { a, b } . S AB + A ; A AS + Sb + a ; B BS + aA + S . (i)To make S A redundant, consider the step in a derivation where a new variable S is produced. (ii)This happens when one of the produc- tions A AS ; A Sb ; B BS ; B S is used. (iii) The only place where S A can play a role is in changing one of these newly produced S ’s into an A . (iv) So adding the rules A AA + Ab and B BA makes S A redundant. (v) We thus obtain the equivalent grammar S AB ; A AS + Sb + a + AA + Ab ; B BS + aA + S + BA . The above is wrong. For example, the grammar no longer generates the string “a”. So the argument must be ﬂawed. The argument consists of ﬁve statements. Find the ﬁrst erroneous statement. Explain. Your answer should be precise and concise. answer: The third statement is false. It does not consider the case when the ﬁrst rule used is S A . 1

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
3. Here is pseudocode to enumerate
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: INXIN : for (plane = 0; 1; plane++) for (i = 0; i <= plane; i++) for (j = 0; j <= plane; j++) if (i + j == plane) print("(i,j)"); Let C i denote the i th C program. We can use this ordering to, for example, run C i on input j for all i, j ∈ IN . (a) Write pseudocode to enumerate INXINXIN . answer: for (plane = 0; 1; plane++) for (i = 0; i <= plane; i++) for (j = 0; j <= plane; j++) for (k = 0; k <= plane; k++) if (i + j + k == plane) print("(i,j,k)"); (b) Assume “halts(i,j,k)” is a subroutine that runs C i on input j for up to k steps and outputs 1 if the program halts in that time-frame (outputs 0 otherwise). Write pseudocode to enumerate the language H = { 2 i 3 j | C i halts on input j } . answer: for (num_steps = 0; 1; num_steps++) for (i = 0; i <= num_steps; i++) for (j = 0; j <= num_steps; j++) if (i + j == num_steps) if halts(i,j,num steps) print(2 i 3 j ); 2...
View Full Document

## This note was uploaded on 06/09/2011 for the course COT 4210 taught by Professor Staff during the Spring '08 term at University of Central Florida.

### Page1 / 2

AnswersH6 - INXIN for(plane = 0 1 plane for(i = 0 i<= plane i for(j = 0 j<= plane j if(i j == plane print"(i,j" Let C i denote the i

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online