Module 5 Worksheet In Class Questions

advertisement
Module 5 Worksheet
In Class Questions
1) (S5) Express the problem {/\, aa} as a LRP in the Input,Yes/No Question format.
Input:
Yes/No Question:
2) (S5) Express the problem {an | n is a perfect square} as a LRP in the Input,Yes/No
Question format.
Input:
Yes/No Question:
3) (S8) Give the shortest possible string that represents a legal program for solving a
language recognition problem.
4) (S16) Prove that the set of natural numbers that are a multiple of 5 is countably
infinite.
5) (S16) Consider the following listing of the set of integers. 0, 1, 2, …, -1, -2, …
Does every integer appear at a finite position?
What does this imply about whether or not the set of integers is countably infinite?
6) (S17) What do we need to do to prove that a set is uncountably infinite?
7) (S21) Write a program that takes as input a non-negative number and outputs the
corresponding string over {a,b}. 0 maps to /\, 1 maps to a, 2 maps to b, 3 maps to aa,
…
8) (S21) Suppose we list all the strings in {a,b}* in alphabetical order. Does every string
appear at a finite position in this list? If so, argue why this is so. If not, give a
counterexample.
9) (S23) What should the declaration for program D look like?
10) (S26) Encode the language of even length strings in this format.
11) (S26) Suppose two rows, say L[3] and L[7], in this list are identical. What does that
imply about the corresponding languages L[3] and L[7]?
12) (S27) In the given example, what strings differentiate D(L[]) from L[0]?
How about L[1]?
Take home review questions
1) Describe in one sentence how we proved that unsolvable problems exist.
2) What is 2{a}* and how is {a}* related to it?
3) The number of legal C++ programs is what?
4) What is true if set S1 has the same size as set S2?
5) I defined D in an algorithmic fashion. What does D take as input and what does D
return as output?
6) How does D determine if D(L[]) contains string an?
7) Fill in Y(P), N(P), C(P), and I(P) for the following program P as best as you can.
bool main(string x) {
P’(5);
if ((x.length( ) % 2) = = 0) return (yes);
else return(no);
}
bool P’(int y) { /* details hidden */ }
Y(P) =
N(P) =
C(P) =
I(P) =
Download