Sunteți pe pagina 1din 17

CS 205 Quiz #10 Dec 6, 2012

NAME: __________________________________________________________________________


RUID:___________________________________________________________________________

Electronic Devices are not permitted during the quiz. These include but are not restricted to calculators,
computers and cell phones.
No communication between students or anyone outside of class is permitted during the quiz.
Textbooks, notes and any other written materials are not permitted during the quiz.

DO NOT OPEN UNTIL
INSTRUCTED TO DO SO


1.
a) Find a proposition using only p, q, and the connective v with the following truth table.


b) Find a proposition using only p, q, and the connective v with the following truth table.


c) Suppose P(x, y) is a predicate and the universe for the variables x and y is {1, 2, 3}.
Suppose P(1, 3), P(2, 1), P(2, 2), P(2, 3), P(3, 1), P(3, 2) are true, and
P(x, y) is false otherwise. Write True in the blank below if the corresponding statement is true,
otherwise write False.


_________________ x -y P(x, y)



_________________ -x y P(x, y)



_________________ -x -y ( P(x, y) . P(y, x) )



_________________ y -x ( P(x, y) P(y, x) )



_________________ x y ( x y ( P(x, y) v P(y, x) ))



_________________ y -x ( x y . P(x, y) )

2.
a) Recall that a set of propositions is consistent if there is an assignment of truth values to each of
the variables in the propositions that makes each proposition true. Determine if the following
set of propositions is consistent. If so, provide an assignment of truth values. If not, explain
why such a setting is impossible.

- The system is in multiuser state if and only if it is operating normally.
- If the system is operating normally, the kernel is functioning.
- The system is operating normally if it is in interrupt mode.
- The kernel is not functioning or the system is in interrupt mode.
- If the system is not in multiuser state, then it is in interrupt mode.
- The system is in interrupt mode.

Use propositions
M = The system is in a multiuser state N = the system is operating normally
P = The kernel is functioning I = the system is in interrupt mode










b) Provide the rule of inference used in each of the following (see beginning of the quiz for rules of
inference). Using variables, indicate the propositions and how they fit the rule of inference.

- If it snows today, the university will be closed. The university will not be closed today.
Therefore, it did not snow today.







- If I work all night on this homework, then I can answer all the exercises. If I answer all the
exercises, I will understand the material. Therefore, if I work all night on this homework,
then I will understand the material.

3.
a) Write True in the blank if the corresponding statement is in CNF. Otherwise, write False.


____________

a

____________

(a v b) . c

____________

a v b

____________

(a . b) v c

____________

a . b

____________

(a v b)

____________

a b

____________

(a b) (c d)

____________

a b

____________

(a b) (c d)

b) Determine whether the following argument is valid. If the argument is valid, demonstrate its
validity either through resolution refutation, or by use of logical equivalences. If the argument is
invalid, provide a counterexample.

If you are not in the tennis tournament, you will not meet Ed.
If you arent in the tennis tournament or if you arent in the play, you wont meet Kelly.
You meet Kelly or you dont meet Ed.
It is false that you are in the tennis tournament and in the play.
Therefore, you are in the tennis tournament.
Use propositions
T = You are in the tennis tournament E = You will meet Ed
P = You are in the play K = You will meet Kelly




4.
a) Suppose a = 3, B = { 3 }, C = { 1, 2, 3} and D = {1, 4, 5}. Mark each of
the following statements as True or False.


_______________

a D

_______________

a B

_______________

a

_______________

a P(B)

_______________

a (B C)

_______________

B { a }

_______________

D

_______________

D D

_______________

B D

_______________

C D = B




b) For each of the following statements, provide the cardinality of the result.



_______________



_______________

({1,2} {3,4}) {5,6}

_______________

{}

_______________

({1,2} {3}) ({3} {2,1})

_______________

{1,2,,}

_______________

P((P({1}) P({2})))

_______________

{} {{}}

_______________

P({1,2} ({3,4} {5,6,7}))

_______________

P(P(P(P())))

_______________

P({1,2,3,4} {5,6,7,8})


5. For each of the relations below, select the most appropriate option and write its letter in the
corresponding blank.

A) A partial function, but not a total function
B) A total function that is not injective, surjective, bijective, or invertible
C) An injective total function, but not an surjective, bijective or invertible function
D) A surjective total function, but not an injective, bijective or invertible function
E) A bijective total function, but not an injective, surjective or invertible function
F) An invertible total function (whose inverse is a total function), but not an injective,
surjective or bijective function
G) A total function that is injective, surjective, bijective and invertible (and whose inverse is a
total function)


___________________ a) f(x) = x - 1, where f : R R


___________________ b) f(x) = x
4
, where f : Z Z


___________________ c) f(x) = (x - 1) / (x + 2), where f : Z R


___________________ d) f(x) = lg x, where f : Z R


___________________ e) f(x) = 1 / x, where f : Z
+
{a R | 0 < a 1}


___________________ f) f(m, n) = 2m / n, where f : Z Z
+
R


___________________ g) f(m, n) = m mod n, where f : N Z
+
N


___________________ h) f(m, n) = m( n, where f : R R Z
( is multiplication)

___________________ i) f(m, n) = -2, where f : R R R


___________________ j) f(m, n) = m - n, where f : Z
-
Z
-
Z


6.
a) Find the least integer n such that the statement is O(x
n
) for each of the following
statements. If no such n is possible, write Impossible.

___________

x

log x

___________

9x
2
+ x

log x

___________

2x
3
+ x
4
log x

___________

7x
2
+ (log x)
4


___________

(x
4
+ x
2
+ 1)/(x
3
+ 1)

___________

x
2
+ 2
x

___________

x



___________

(0.3)
x
+ 4x
5


___________

12

___________

5/x + 4/(x!)


b) What is the effect in the time required to solve a problem when you increase the size of the
input from n to n+1, assuming that the number of milliseconds the algorithm uses to solve
the problem with input size n is each of the quantities expressed below? Let W
1
denote the
runtime with input size n+1 and let W
0
denote the runtime with input size n. In each blank,
write the corresponding letter from the table below. Note that an option may be used zero or
more times (i.e. once, more than once, not at all).

A) W
1
- W
0
= 0 B) W
1
- W
0
= 1 C) W
1
- W
0
= 2
D) W
1
- W
0
= n E) W
1
- W
0
= 2n F) W
1
- W
0
= 2n+1
G) W
1
- W
0
= n+1 H) W
1
- W
0
= 2n-1 I) W
1
- W
0
= lg(n+1)
J) W
1
- W
0
= lg(n+1) lg(n) K) W
1
/ W
0
= 2 L) W
1
/ W
0
= 2n
M) W
1
/ W
0
= n+1 N) W
1
/ W
0
= 2n+1 O) W
1
/ W
0
= 2n+2
P) W
1
/ W
0
= lg(n) Q) W
1
/ W
0
= n
2
R) W
1
/ W
0
= n!
S) W
1
/ W
0
= 2
n
T) W
1
/ W
0
= 2
n+1
U) W
1
/ W
0
= 2
(2n+1)



___________

3

___________

n + 1

___________

2n + 1

___________

n
2


___________

n
2
+ n

___________

n!

___________

2
n


___________

2 ^ (n
2
)

___________

lg n

___________

(n-1)
2


7.
a) For the pair of graphs below, determine whether they are isomorphic. If the graphs are
isomorphic, then fill in blanks to indicate which vertex in the first graph maps to which other
vertex in the second graph. If the graphs are not isomorphic, then provide a clear reason.





b) Determine if the following graph is bipartite. If so, provide the partitions. If not, provide a clear
reason.


c) How many subgraphs that are cycles can be produced from a complete graph with 4 vertices?




d) What is the sum of the degrees over all vertices in a complete graph with 10 vertices?




e) What is the maximum and minimum number of edges in a graph with 5 vertices?

a _________

d _________

b _________

e _________

c _________

f _________

8.
a) For each of the following trees, provide the preorder, inorder and postorder traversal:


i.
Preorder:


Inorder:


Postorder:


ii.
Preorder:


Inorder:


Postorder:



b) For the following codes, compute the average number of bits to encode a single character if the
character frequencies are as shown. Additionally, specify whether or not the code is a Huffman
code (write True if it is a Huffman Coding, otherwise write False).

code: a: 0, b: 100, c: 101, d: 110, e: 111
frequencies: a: 0.40, b: 0.19, c: 0.15, d: 0.13, e: 0.13


Average Bits: ____________________ Huffman Code: ________________


c) Compute the value of the prefix expression + - 3 2 2 3 / 6 4 2


d) Compute the value of the postfix expression 1 2 * 2 5 3 8 4 / * -



9.
a) Consider grammar G = (V, T, S, P) where V = { A, B, a, b, S } and
T = { a, b }. The set of productions P in Backus-Naur form are:
S ::= AB
A ::= aAb |
B ::= bBa |

Determine whether each of the following is derivable starting from S. Write True if it
is derivable and False if it is not derivable.



_______________

a

_______________

ab

_______________

aba

_______________

abba

_______________

abbbaa

_______________

abab

_______________

ababa

_______________

ababab

_______________

aaaabbbbba

_______________





b) Find a set of exactly 3 productions that produces {1
n
01
2n
0 | n 0}.
Use only nonterminals S and A, where S is the start symbol.






c) Find a context-free grammar that generates the complete set of all strings over the alphabet
{0, 1} such that there are always more 1s than 0s. (It generates all such strings and no
other types of strings.) List the productions in the space provided below. Use only six
productions and only two nonterminals, S and A.

The following tables reprinted from the textbook may be useful to you:




Scratch Paper


Scratch Paper


Scratch Paper


Scratch Paper


Scratch Paper

S-ar putea să vă placă și