Docsity

Problems on the Pseudorandom Sequence - Midterm Exam | CECS 228, Exams of Discrete Structures and Graph Theory

Toggle sidebar
bg1
Midterm 2: CECS 228
Darin Goldstein
Instructions: Do the following problems and indicate your answer by circling it/them. If I cannot clearly
read and understand your responses, they will be marked wrong. Unless otherwise indicated by a (Circle all
that apply.), only circle a single answer. In order to get a problem correct, it must be entirely correct. No
partial credit will be given for multiple choice problems.
For the short answer questions, you will be given partial credit as outlined in the syllabus.
IMPORTANT: You may not consult with any other human being (other than the professor) in any way
(including but not limited to electronic means such as the internet) for the purposes of completing this exam.
If I find sufficient evidence that two or more people have collaborated on this exam (including but not limited
to answers that are inexplicably similar), ALL PARTIES WILL RECEIVE AN AUTOMATIC FAILING
GRADE FOR THE COURSE INDEPENDENT OF WHO DOES THE WORK. It is your responsibility
to make sure that someone else does not cheat off of your exam. The professor reserves the right at his
discretion to ask students to explain or repeat the reasoning for any question and deal appropriately with
an obvious lack of knowledge.
1
pf3
pf4
pf5

Partial preview of the text

Download Problems on the Pseudorandom Sequence - Midterm Exam | CECS 228 and more Exams Discrete Structures and Graph Theory in PDF only on Docsity!

Midterm 2: CECS 228

Darin Goldstein

Instructions: Do the following problems and indicate your answer by circling it/them. If I cannot clearly read and understand your responses, they will be marked wrong. Unless otherwise indicated by a (Circle all that apply.), only circle a single answer. In order to get a problem correct, it must be entirely correct. No partial credit will be given for multiple choice problems. For the short answer questions, you will be given partial credit as outlined in the syllabus. IMPORTANT: You may not consult with any other human being (other than the professor) in any way (including but not limited to electronic means such as the internet) for the purposes of completing this exam. If I find sufficient evidence that two or more people have collaborated on this exam (including but not limited to answers that are inexplicably similar), ALL PARTIES WILL RECEIVE AN AUTOMATIC FAILING GRADE FOR THE COURSE INDEPENDENT OF WHO DOES THE WORK. It is your responsibility to make sure that someone else does not cheat off of your exam. The professor reserves the right at his discretion to ask students to explain or repeat the reasoning for any question and deal appropriately with an obvious lack of knowledge.

  1. (5 points) What is the 4th number (i.e. x 3 ) in the pseudorandom sequence generated using the linear congruential generator xn+1 = (4xn + 1) mod 7 with seed x 0 = 3?

(a) 10 (b) 11 (c) 12 (d) 13 (e) NONE OF THE ABOVE

  1. (5 points) What does the following recursively defined set S represent? (Let λ be the empty string.)

λ ∈ S, s ∈ S → 0 s 0 ∈ S, s ∈ S → 1 s 1 ∈ S

(a) The set of all palindromic binary strings. (b) The set of all even length palindromic binary strings. (c) The set of all odd length palindromic binary strings. (d) The set of all binary strings. (e) NONE OF THE ABOVE

  1. (5 points) Consider the following recursive definition of a sequence an: a 0 = 0, ai+1 = 2 − ai. What is a nonrecursive way of writing this sequence?

(a) an = 1 − (−1)n (b) an = 1 + (−1)n (c) an = 2n (d) an = n + 2 (e) NONE OF THE ABOVE

  1. (5 points) Consider the following recursive function f (a, n): If a ≤ 1, return n. If a > 1, then return f ( a 2 , n + 1). What does the function f (x, 0) compute assuming that x ≥ 1?

(a) f (x, 0) = x! (b) f (x, 0) = 2x (c) f (x, 0) = 2x (d) f (x, 0) = blog xc (e) NONE OF THE ABOVE

  1. (5 points) Consider the following recursive function f (a, b): If a < b, return f (b, a). If b = 0, return a. Otherwise, return f (b, a − b). What is the result of computing f (x, y) if x and y are both positive integers?

(a) 0 (b) max{x, y} − min{x, y} (c) lcm(a, b) (d) blogb ac (e) NONE OF THE ABOVE

  1. (20 points) Prove that

1 +

n^2

n whenever n is a positive integer greater than 1.

  1. (20 points) Assume that two players are playing the following game. Assume that a referee throws down n marbles into a circle drawn on the floor. The two players then take turns removing marbles from the center of the circle. First, Player 1 removes either 1, 2, or 3 marbles; then Player 2 removes either 1, 2, or 3 marbles; then, Player 1 removes either 1, 2, or 3 marbles; and so on until there are no marbles left to remove. It is up to the players to decide how many marbles they wish to remove during each turn (at least 1 but at most 3). The player that is forced to remove the last marble from the circle loses the game. Notice that it does not matter how many marbles a player winds up with in the end, only whether he is forced to remove the last marble from the circle that determines whether he wins the game. The goal of this exercise will be to prove that Player 2 will win this game (assuming both players play optimally) if and only if the number n of marbles in the circle at the beginning of the game is 1 more than a multiple of 4. - Prove that the above assertion is true if n = 1.

For the remaining parts of this proof, we will use strong induction. Assume that the assertion is true for all numbers k < n.

  • Show that the assertion is true if n IS 1 more than a multiple of 4.
  • Show that the assertion is true if n IS NOT 1 more than a multiple of 4.
  1. (20 points) The Cantor expansion of a positive integer x is a sum of the form

x = ann! + an− 1 (n − 1)! +... + a 2 2! + a 1 1!

where ai must be an integer such that 0 ≤ ai ≤ i for i = 1, 2 ,... , n. It is possible to find a Cantor expansion for any positive integer x. Prove that the Cantor expansion is “unique” in the following sense: Let f be the function that takes the digits of a Cantor expansion anan− 1... a 2 a 1 where 0 ≤ ai ≤ i for i = 1, 2 ,... , n to its corresponding positive integer x. Prove that the function f is one-to-one.