MAT 2051 Discrete Mathematics Unit 6 Quiz 3
MAT 2051 Discrete Mathematics Unit 6 Quiz 3
Question 1 How many times does the computer print the string “Hello”?
i = 2
while (i < 4) {
print (“Hello”)
i = i + 1}:
Answers:
a. 1.
b. 2.
c. 3.
d. 4.
Question 2Which of the following is O(n)?
Answers:
a. 3n + 1.
b. n * log(n).
c. n * n + n.
d. None of the above.
Question 3 If each of the following describes the run time of an algorithm, which of the following could have the longest run time?
Answers:
a. O(nlog(n)).
b. O(n!).
c. O(n/2).
d. O(n * n).
Question 4What does the following algorithm return?
f(n){
if (n< 2)
return 1
else
return f(n – 1) * n:
Answers:
a. n!
b. The maximum divisor of n.
c. (n – 1)!
d. n 2.
.Question 5 Given that S_n denotes the number of n-bit strings that do not contain the pattern 00, what are the initial conditions?
Answers:
a. S_1 = 2, S_2 =3.
b. S_1 = 1, S_2 =2.
c. S_1 = 0, S_2 =2.
d. None of the above.