2. The solution to the Towers of Hanoi problem with n disks requires 2n – 1 move
ID: 3685132 • Letter: 2
Question
2. The solution to the Towers of Hanoi problem with n disks requires 2n – 1 moves. If each move requires the same time m, the solution requires ______ time units.
a. (2n - 1) * m
b. (2n - 1) / m
c. (2n - 1) + m
d. 2n - 1
3. Consider an algorithm that contains loops of this form:
for (i = 1 through n)
{ for (j = 1 through i)
{ for (k = 1 through 10)
{ Task T
}
}
}
If task T requires t time units, the innermost loop on k requires ______ time units.
a. j
b. 10
c. k * t
d. 10* t
4. Which of the following growth-rate functions grows the slowest in value?
a. 1
b. n
c. n2
d. log2 n
5. The values of the growth-rate function O(log2 n) grow faster than the values of the growth-rate function O(n).
a. True
b. False
Explanation / Answer
2)
= (2n-1) * m
Thus the correct option is a. (2n - 1) * m
3)
= 10* t
Thus the correct option is d. 10* t
4)
Thus the correct option is d. log2n.
5)
Thus the correct option is b. False.
n log2n n 2 1 2 4 2 4 8 3 8 16 4 16 32 5 32Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.