Question: Consider the following function which takes as input an array A of size n. For this problem use the unit cost model as a function

Consider the following function which takes as input an array A of size n. For this problem use the unit cost model as a function of n and d (assume n = 3^k ).

function mystery (A) // Assume A is an array of size n

(B, C, D) =divide(A) // divide takes time n^d

b = mystery(B) // B is of size floored[A/3]

c = mystery(C) // C is of size floored[A/3]

d = mystery(D) // D is of size floored[A/3]

return b + c + d // takes (1) time

Give a recurrence formula describing the running time

Draw the recursion tree showing level 0, level 1, level 2, level i, and level log3 n

How many subproblems are at level i of the recursion tree?

What is the cost of a single problem at level i of the recursion tree?

What is the total cost of level i of the recursion tree?

How many levels are in the recursion tree?

Write the total cost as a sum of the levels.

Simplify the sum of the total cost. Show your steps.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!