  How many lines does his algorithm print? Write a recurrence and solve it.function printaton(n: an integer power of 2) {               if n > 1 {                      printaton(n/2)                       printaton(n/2)                      printaton(n/2)                      for i = 1 to n ^ 4 do                            printline("are we done yet?")                }}a. Use Master's theorem to obtain an asymptotic solution.b. Derive an exact solution by expanding the recurrence.

Question

How many lines does his algorithm print? Write a recurrence and solve it.
function printaton(n: an integer power of 2) {
if n > 1 {
printaton(n/2)
printaton(n/2)
printaton(n/2)
for i = 1 to n ^ 4 do
printline("are we done yet?")
}
}

a. Use Master's theorem to obtain an asymptotic solution.

b. Derive an exact solution by expanding the recurrence.

Step 1

The given program splits into three subprograms with half of the input size each and then prints n^4 lines.

Hence, The recurrence is T(n) = 3T(n/2) + n^4 , T(1) = 1

1. Using master theorem...

Want to see the full answer?

See Solution

Want to see this answer and more?

Our solutions are written by experts, many with advanced degrees, and available 24/7

See Solution
Tagged in

Algorithms 