Docsity

Sample Midterm Exam 1 - Computability and Languages | CSE 460, Exams of Computer Science

Toggle sidebar
bg1
CSE 460 - Sample Midterm 1
Exam
Fall Semester, 2003
The total points are as follows:
The type A points on this exam sum to 13.
The type B points on this exam sum to 16.
The type C points on this exam sum to 13.
The type D points on this exam sum to 13.
1. Consider the following pseudocode program P.
bool main(int n) {
if (n < 3 ) return(no);
int i = 7;
while ( i != n ) i--;
return(yes);
}
(a) What is Y(P)? [2, A]
(b) What is N(P)? [2, A]
(c) What is I(P)? [2, A]
(d) Is Y(P) solvable? Explain why or why not. [2,C]
1
pf3
pf4
pf5

Partial preview of the text

Download Sample Midterm Exam 1 - Computability and Languages | CSE 460 and more Exams Computer Science in PDF only on Docsity!

CSE 460 - Sample Midterm 1

Exam

Fall Semester, 2003

The total points are as follows: The type A points on this exam sum to 13. The type B points on this exam sum to 16. The type C points on this exam sum to 13. The type D points on this exam sum to 13.

  1. Consider the following pseudocode program P.

bool main(int n) { if (n < 3 ) return(no); int i = 7; while ( i != n ) i--; return(yes); }

(a) What is Y (P )? [2, A]

(b) What is N (P )? [2, A]

(c) What is I(P )? [2, A]

(d) Is Y (P ) solvable? Explain why or why not. [2,C]

  1. In this problem, we will attempt to prove that RE is closed under the set difference operation.

(a) What is {a, ab, aaa, aab} − {a, b, ba, baa}? [1, A]

(b) Express the fact that RE is closed under the set difference operation as a first-order logic statement or an if-then statement. [2, A]

(c) Fill in the blanks in the following outline of a generic element proof that RE is closed under the set difference operation. [2, B]

  • Let be arbitrary.
  • Let be programs that.
  • Construct program P ′^ from.
  • Argue.
  • There exists a program P that.
  • Therefore, is.

(d) Consider the following candidate program P ′: bool main(string z){ if (P 1 (z) && !P 2 (z)) return (yes); else return (no); } bool P 1 (string z) { /* details hidden / } bool P 2 (string z) { / details hidden */ } i. Identify the set of strings P ′^ processes incorrectly. [1,D]

ii. State what P ′^ should do on this set of strings. [1,D]

iii. State what P ′^ actually does on this set of strings. [1,D]

  1. Consider the Failure Problem F AIL that is defined as follows:
    • Input: Program P , nonnegative integer x (an input to program P ).
    • Yes/No Question: Does P loop or crash on x?

Assume PF is a program that solves F AIL. Consider the following incomplete program D.

bool main(unsigned int y) { program P = generate(y); if (PF (P, y)) Action A; else Action B; } program generate(unsigned int y); bool PF (program P, unsigned int y);

(a) What does it mean if PF (P, y) evaluates to true? [1,B]

(b) What does it mean if PF (P, y) evaluates to false? [1,B]

(c) In order to complete program D, what actions would be appropriate? Circle all that apply. [2, D] Action A: Accept, Reject, Loop, Crash Action B: Accept, Reject, Loop, Crash (d) Explain your answer to part (c). [2, D]

  1. Suppose we try to prove that the following list of problems is unsolvable using our standard approach of creating an input transformation program PT that takes as input an input to the Halting Problem (program QH , non-negative integer y that is an input to QH ) and produces as output a program QL. For each problem, state whether or not we would need PT to compute - An answer-preserving input transformation - An answer-reversing input transformation

Justify your answer for the last problem on the list. [6,D]

(a) Input: A program P that takes as input a string over {a, b} Yes/No Question: Is Y (P ) infinite?

(b) Input: A program P that takes as input a string over {a, b} Yes/No Question: Is I(P ) infinite?

(c) Input: A program P that takes as input a string over {a, b} Yes/No Question: Is Y (P ) solvable?

(d) Input: A program P that takes as input a string over {a, b} Yes/No Question: Is N (P ) = {}?

  1. Label each statement as true (T) or false (F), no justification necessary. [5,C]

(a) Every solvable problem is also half-solvable. (b) RE is closed under the set complement operation. (c) Program behavior problems are generally solvable. (d) It is ok for a program that half-solves a language L to loop on a string x ∈ L. (e) If L 1 is half-solvable and L 2 is finite, then L 1 ∩ L 2 is solvable.

  1. Describe Y (P ) as completely as you can for the following program P. Type string is defined over alphabet {a,b}. [2,B] Program P:

bool main(string z){ Q 1 (5); if (z[0] == b) return(yes); else return(no); } bool Q 1 (int x) {/* details not provided */}

  1. Church’s Thesis

(a) State our modified version of Church’s Thesis. [2, A]

(b) Describe the significance of our modified version of Church’s Thesis. [2, C]