Question

In: Computer Science

In class, we learned that the running time of Karatsuba’s algorithm can be expressed as the...

  1. In class, we learned that the running time of Karatsuba’s algorithm can be expressed as the recurrence T (n) = 3T (n/2) + n. We then used the substitution method to solve the recurrence.

    When using the substitution method, it seems difficult to make a guess about the upper bound on the running time. However, if we use the recursion tree method, it would be a lot easier.

    In this question, you are asked to solve this recurrence using the recursion tree ap- proach, which can be further used to help us make the guess (you are not required to explain how to make use of your result to make the guess; only show your work using the recursion tree). You can assume that T(1) = 1 and that n is a power of 2 for convenience. Give your solution using big-Oh notation.

Solutions

Expert Solution

Given Recursion :

T(n) = 3T(n/2)+n

Recursion solution using Tree Approach:

So basically,if we draw out the recursion tree then we will find that,

the number of level's in the recursion tree will be as

h=log2⁡n+1 , where h = height of the tree

and the number of leave's in the recursion tree will be

3ℎ−1= 3log2(?) [h = log2⁡n+1 ]

= ?log23

Now we will be able write the time formula as the foloowing:

T(n) = cn + c(3n/2) + c(9n/4) + ......+ cn(3h-2 / 2(h-2)) + Θ(?log23)

Explanation:

  

So we will be able to solve this using Masters theorem, but also we can solve by creating the recursion tree in the following way as given below:

1. At the top of  the root of the recursion tree which we created ,we  will be have a work of n.

2. In the second step or we can say that in  the second stage, the recursion tree splits into three parts / division's, and in each part, the work will be n / 2.

3. We will Keep going until we will reach out to the leaves of the recursion tree and the entire work leaf will be:

O (1) = O (n / 2 k)

when: n = 2 k

4. we know that at each / every step m have 3 m splits / parts further in the recrsion tress.

5. Now we will  combine all the steps together by using the geometric progression and logarithms rules.

and by solving the below equation which we obtained as below

T(n) = cn + c(3n/2) + c(9n/4) + ......+ cn(3h-2 / 2(h-2)) + Θ(?log23)

It will give the Time complexity as:

?(?)=Θ(?log23)


Related Solutions

Suppose that we performed the algorithm SELECT whose running time is O(n) on 133 elements, and...
Suppose that we performed the algorithm SELECT whose running time is O(n) on 133 elements, and found the median of medians x by making groups of 5 elements. What is the maximum number of elements which are guaranteed to be greater than equals to x (without counting x, itself)?
Write an algorithm to evaluate an infix expression in Java. Calculate its running time
Write an algorithm to evaluate an infix expression in Java. Calculate its running time
Pseudocode and algorithm of merging k sorted list with running time O(Nlogk).
Pseudocode and algorithm of merging k sorted list with running time O(Nlogk).
Can we predict the running time for Mr. Degges when he runs 3.1 miles on the...
Can we predict the running time for Mr. Degges when he runs 3.1 miles on the track at the NDSU Wellness center? Need: SAS output to analyze the model Need: prediction equation y-hat SSE SST, error, F-test What variables are significant The variables are: Y = running time in minutes X1 = weight at the time of running X2 = number of days between running events Year X1 X2   Y 2009 191.2 1 29.0 2009 192 1   27.80 2009 190.4...
part a. In class we learned that the debugger, and _________ are effective in debugging C++...
part a. In class we learned that the debugger, and _________ are effective in debugging C++ programs. a. a logic analyzer b. print statements c. code reviews d. network analyzers part b. A ‘side-effect’ is a. code written in a memory-efficient way b. a style of writing C++ statements that is risky. c. code written so that more than one thing is being done in one statement. d. (a) and (b) e. (b) and (c) f. none of the above...
We have learned about conditioning in class. There are countless ways that we encounter condition in...
We have learned about conditioning in class. There are countless ways that we encounter condition in everyday life. This assignment requires that you examine conditioning (either classical or operant) as you’ve experienced it. Provide five examples of conditioning from your own life with a detailed description of stimulus/response and reinforcement patterns.​
Give the asymptotic (“big-Oh”) running time complexity of the following algorithm, show all the work you...
Give the asymptotic (“big-Oh”) running time complexity of the following algorithm, show all the work you have done. Algorithm: ArrayMangle(A[ ], int n) Input: an array A, an integer n x = 0; for (i=0; i<=n-1; i++) { for (j=i; j<=n-1; j++) { x = x + A[j]; } for (k=0; k<= n-1; k++) { for (j=0; j< =n-1; j++) { x = x + A[j]*A[k]; } } }
In class, we learned that ”most” of the sun’s radiation happens in the band 0.2 ?...
In class, we learned that ”most” of the sun’s radiation happens in the band 0.2 ? ? ? 3µm, and Stephen asked what ”most” means. What proportion of solar radiation (for a black body sun) falls in the above wavelength range. Similarly, what proportion of the Earth’s radiation (black body Earth at 290K) occurs in the wavelength band 4 ? ? ? 40µm? What wavelength range contains the middle 95% of the sun’s radiation?
In class we learned that investors should always hold a portfolio that is on the efficient...
In class we learned that investors should always hold a portfolio that is on the efficient frontier. In reality investors often hold a portfolio that is not on the efficient frontier. One reason for this is called home bias. Home bias refers to the fact that investors tend to have larger portfolio weights on assets that are located in the country in which they live. So, American investors tend to have a larger portfolio weight on American firms than is...
In class we learned that, if terms added in a series continually decrease in size, the...
In class we learned that, if terms added in a series continually decrease in size, the terms will eventually be too small to be stored by MATLAB. When a number is too small to be stored, we learned that such a situation is called underflow; in this case, MATLAB will just store it as 0. We also learned that a program computing such a series can terminate the loop when the next term to be added is equal to 0...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT