Module 4 Worksheet In Class Questions 1) (S4) Decision sorting:

advertisement

Module 4 Worksheet

In Class Questions

1) (S4) Decision sorting:

Input: list of integers

Yes/ No Question: is the list in nondecreasing order?

For the decision sorting problem, specify the following sets

Universe of legal input instances:

Set of yes input instances:

Set of no input instances:

2) (S5) Define the set of no input instances for the following decision problem

Universe of legal input instances: Set of all positive integers

Universe of yes input instances: Set of positive numbers that are divisible by 3

Universe of no input instances:

2) (S7) Specify the language recognition problem for L = the set of even length strings

over {a,b} using both formats (traditional, 3 sets).

Input:

Yes/No question:

Universe of legal input instances:

Set of yes input instances:

Set of no input instances:

4) (S9) Define an encoding scheme E for converting the following problem into a language recognition problem over alphabet {a}.

Input: Non-negative integer n

Yes/No question: Is n a prime number?

What would E(4) be under your scheme?

What is the resulting language L?

5) (S11) Suppose a program P is designed to solve some decision problem

. What does

P’s declaration look like?

6) (S11) What should P do on a yes input instance/no input instance?

7) (S23) Which is true? a) A problem is solvable implies the problem is half-solvable. b) A problem is half-solvable implies the problem is solvable.

Take home review questions

1) What is the type of an input instance in a language recognition problem?

2) Give both formulations (Input & Y/N question, 3 sets) of the LRP corresponding to the language L = the set of strings beginning with aaa over {a,b}.

3) What are Y(P), N(P), C(P), and I(P) for the following program?

bool main(string x) {

if ((x.length( ) % 2) = = 0) return (yes);

else return(no);

}

Y(P) =

N(P) =

C(P) =

I(P) =

4) For any program P that takes as input a string, can P ever solve a language other than

Y(P)?

Download