1. Analysis of the time complexity of a recursive algorithm has resulted in the following recurrence equations. $\qquad T(1) = 1$ $\qquad T(n) = n^2 + 4T(\frac{n}{2}) \quad for \quad n > 1$ (a) Use the top-down method to find a closed-form solution for $T(n)$. (Recap: the top-down method is one in which you use the recurrence equations to rewrite $T(n)$ in terms of $T(x)$ where $x < n$ and repeat the process until you reach the base case.) (b) Draw a recursion tree to get a closed-form solution for $T(n)$. Use the notation in the class (show the input size within each node, annotate it with the the non-recursive time, indicate the number of nodes at each level, the non-recursive time for each level near the right margin, and the grand total vertically below). Your tree must include at least three topmost levels including the root and two bottom-most levels including the leaf.
Added by Sherri N.
Close
Step 1
T(n) = n^2 + 52 + 4T(1) = (n-1)^2 + 52 + 4T(1) = (n-2)^2 + 52 + 4T(1) = ... = (1)^2 + 52 + 4T(1) Now, we have reached the base case T(1). Let's substitute T(1) with a constant c: T(n) = 1 + 52 + 4c Show more…
Show all steps
Your feedback will help us improve your experience
Mohan Jain and 59 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Give asymptotic upper and lower bounds for T(n) in each of the following recurrences. Assume that each T(n) is constant for n ≤ 2. Make your bounds as tight as possible (in other words, give Θ bounds where possible) and make sure to justify your answers. Do not just apply a theorem to solve these recurrences. Show your work. Drawing out a recursion tree, repeatedly unrolling the recurrence, and creating a table are very useful techniques for analyzing these recurrences. (a) T(n) = T(n − 1) + n (b) T(n) = T(n − 1) + 1/n (c) T(n) = T(9n/10) + n (d) T(n) = 4T(n/2) + n (e) T(n) = 3T(n/2) + n^2
Frank D.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Watch the video solution with this free unlock.
EMAIL
PASSWORD