Discrete Mathematics Midterm Exam

Thursday, April 23, 2008

Computer Science and Engineering, SNU

1. (10 points) Determine whether

[eqn: ( LNOT q WEDGE `(p -> q))` -> ` LNOT p] is a tautology.

2. (20 points) Let I(x) be the statement "x has an

Internet connection" and C(x,y) be the statement

"x and y have chatted over the Internet," where

the domain for the variables x and y consists of

all students in your Class. Use quantifiers to

express each of these statements.

a) Sanjay has chatted with everyone except

Joseph.

b) Exactly one student in your class has an

Internet connection.

c) There are two students in the class who

between them have chatted with everyone else

in the class.

3. (20 points) Prove that if [eqn: n] is an integer

and [eqn: 3n+2] is even, then [eqn: n] is even using

a) a proof by contraposition.

b) a proof by contradiction.

4. (20 points) Give a big-O estimate for

each of these functions. For the function

g in your estimate that [eqn: f(x)] is [eqn: O(g(x))],

use a simple function [eqn: g] of the smallest

order.

a) [eqn: n log(n^2 +1) + n^2 logn]

b) [eqn: (n log n +1)^2 + (log n +1 )(n^2 +1)]

c) [eqn: n^2^n + n^n^2]

d) [eqn: H_n = 1+ 1 over 2 + 1 over 3 + ... 1 over n]

5. (10 points) Answer the following

questions on the relationship between the

discrete structures.

a) Show that a propositional operator can

be viewed as a function.

b) Show that a set union operation can

be defined as a function.

6. (10 points) Answer the following questions on search algorithms.

a) Compare the average number of comparisons

needed to find an element in a list of 32

elements using linear search and binary

search. The element is equally likely to be in

any position.

b) Suppose that an element is known to be

among the first four elements in a list of 32

elements. Would a linear search or binary

search locate this element more rapidly?

7. (20 points) The following pseudo-code describes an

algorithm for assigning men and women. Answer     the following questions.

procedure stable([eqn: M_1 , M_2 , ... M_s , W_1 , W_2 , ... W_s]:

preference lists)

for [eqn: i]:=1 to [eqn: s]

begin

mark man [eqn: i] as rejected

set man [eqn: i]'s rejection list to be empty

set woman [eqn: i]'s proposal list to be empty

end

while rejected men remain

begin

for [eqn: i]:=1 to [eqn: s]

if man [eqn: i] is marked reject then add [eqn: i] to the

proposal list for the woman [eqn: j] who ranks

highest on his preference list but does not

appear on his rejection list, and mark [eqn: i] as

not rejected

for [eqn: j]:=1 to [eqn: s]

if woman [eqn: j]'s proposal list is nonempty then

remove from [eqn: j]'s proposal list all men [eqn: i]

except the man [eqn: i_0] who ranks highest on her

preference list, and for each such man [eqn: i]

mark him as rejected and add [eqn: j] to his

rejection list

end

for [eqn: j]:=1 to [eqn: s]

match [eqn: j] with the one man on [eqn: j]'s proposal list

a) What is the worst-case time complexity of the

algorithm?

b) What is the average-case time complexity of

the algorithm, given that all men's preference

lists are equal?

(110 points total)