0% found this document useful (0 votes)
5 views

Week 11

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Week 11

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Discrete Mathematics - Week 11

1. Which of the following statement(s) is/are true?

I) The solution for the Tower of Hanoi is 2n − 1.


II) The recurrence relation for the Tower of Hanoi is T (n) = 2T (n−1)+1 for T1 = 1.
III) The complexity of the Tower of Hanoi is 2n .

Select all that apply:

(a) I and II
(b) I and III
(c) II and III
(d) I, II, and III

Correct Answer: I, II, and III


Solution: All the given statements are correct.
Refer to Lecture: Tower of Hanoi.

2. Which of the following is/are true with respect to the growth of the function?

(a) 7n2 < n4


(b) n3 < 10n2
(c) 8n > n4
(d) 150n < 12n4

Correct Answer: (a),(d)


Solution: The initial behavior of the function is not as important as its growth rate
over time. The coefficient in front of the variable does not influence the growth rate
for large values of n.
Refer to Lecture: Intuition for ‘complexity’.

3. Let bn be a sequence that satisfies the recurrence relation bn = 15bn−1 − 20bn−2 where
b0 = 3 and b1 = 9. What are b3 and b4 respectively?

(a) 945, 12675


(b) 125, 2520
(c) 3990, 84700
(d) 140, 2520
Correct Answer: (a)
Solution: Given that bn = 15bn−1 − 20bn−2 and b0 = 3, b1 = 9
For n = 3, b3 = 15b3−1 − 20b3−2 ; b3 = 15b2 − 20b1
We need to find b2
For n = 2, b2 = 15b1 − 20b0 = b2 = 15(9) − 20(3) = 135 − 60 = 75
Now, b3 = 15b2 − 20b1 = 15(75) − 20(9) = 1125 − 180 = 945
And, b4 = 15b3 − 20b2 = 15(945) − 20(75) = 14175 − 1500 = 12675

4. Consider the recurrence relation bn = bn−1 + 3n, with the initial term b0 = 5. What
is the closed-form expression for bn ?

(a) 3n + 5
3n(n+1)
(b) 2 +5
(c) n2 + 5
(d) 6n2

Correct Answer: (b)


Solution:
Write the terms as the difference between consecutive terms:

bn − bn−1 = 3n

Now, write down b1 − b0 , b2 − b1 , ..., bn − bn−1 , and add them up.


They will cancel out, and you’ll get:

bn − 5

On the right-hand side, you will get:


 
n(n + 1)

2

So:
3n(n + 1)
bn = +5
2
Refer to Lecture: Solving recurrence relation Example 2

5. Which of the following is the correct recurrence relation for climbing 12 stairs? Climb-
ing stairs simply means walking on stairs, covering one stair in one step.

(a) a12 = a11 + a10


(b) a12 = a12 + a10
(c) a12 = a12 + a11
(d) a12 = a10 + a9
Correct Answer: (a)
Solution: an = an−1 + an−2 are the total ways to reach the nth step after climbing
stairs.
Lecture 410: Number of ways of climbing steps Recursion relation.

6. Alex is working on a large database containing 1024 records. While he is examining


a particular record, his colleague interrupts him for a brief discussion. In his haste,
Alex forgets to mark the record he was working on, though he remembers its number.
How much effort will Alex require to locate the record he was last examining?

(a) log(512)
(b) log(2048)
(c) log(1048576)
(d) log(1024)

Correct Answer: (d)


Solution: The situation can be interpreted as a problem of binary search. The com-
plexity of binary search is log(n). Therefore, Alex needs to perform log(1024) work
to locate the last examined record.
Refer to Lecture: Solution for the recurrence relation of Binary search.

7. Which of the following sequence(s) is/are correct?

(a) O(log(n)) < O(n) < O(n2 ) < O(n log(n))


(b) O(n) < O(n2 ) < O(log(n)) < O(n log(n))
(c) O(log(n)) < O(n) < O(n log(n)) < O(n2 )
(d) O(n) < O(n2 ) < O(log(n)) < O(n log(n))
(e) O(n log(n)) < O(log(n)) < O(n) < O(n2 )

Select all that apply:

(a) I and III


(b) II and IV
(c) I and V
(d) III only
(e) I, III, and IV

Correct Answer: (d)


Solution: For large values of n, the correct order of growth is:

O(log(n)) < O(n) < O(n log(n)) < O(n2 )

Hence, only (d) follows this correct order.


8. How many n-bit binary strings are possible without having consecutive zeros?

(a) T (n) = T (n − 1) + T (n − 2) such that T (1) = 2 and T (2) = 3


(b) T (n) = T (n − 1) + T (n − 2) such that T (1) = 1 and T (2) = 2
(c) T (n) = T (n) + T (n − 1) such that T (1) = 1
(d) T (n) = T (n − 2) + T (n − 3) such that T (1) = 2 and T (2) = 3

Correct Answer: (a)


Solution: The recurrence relation T (n) = T (n − 1) + T (n − 2) accurately describes the
problem of counting n-bit binary strings without consecutive zeros. The base cases
are T (1) = 2 (possible strings are ”0” and ”1”) and T (2) = 3 (possible strings are
”00,” ”01,” and ”10”).

9. Given the sequence {0, 1, 1, 2, 3, 5, 8, 13, . . .}, find the 12th term of this sequence. Note
that the zeroth term of the sequence is 0.

(a) 233
(b) 144
(c) 89
(d) 377

Correct Answer: (b)


Solution: The sequence given in the question is the Fibonacci sequence.
In the Fibonacci sequence, an is given by:

√ !n √ !n
1 1+ 5 1 1− 5
an = √ −√
5 2 5 2

Therefore, the 12th term is:

√ !12 √ !12
1 1+ 5 1 1− 5
a12 =√ −√ = 144
5 2 5 2

Lecture 420: Solution of Fibonacci sequence.

10. Consider the following functions:

f1 (n) = 3n4 + 2n3 + 6


f2 (n) = 43
f3 (n) = 82
f4 (n) = 2n2 + 10

Which of the following statements is/are true?


(a) f2 (n) is an order n function
(b) f4 (n) grows slower than f1 (n)
(c) f1 (n) is an order n4 function
(d) f3 (n) grows faster than f4 (n)

Correct Answer: (b),(c)


Solution:

• f2 (n) = 43 is a constant function (not an order n function).


• f4 (n) = 2n2 + 10 grows slower than f1 (n) = 3n4 + 2n3 + 6 because f1 (n) is a
polynomial of higher degree.
• f1 (n) is indeed an order n4 function, which means it grows at the rate of n4 .
• f3 (n) = 82 is also a constant function and does not grow with n, so it grows
slower than f4 (n).

You might also like