How can I prove the $T(n) = 2T(n/2) + n$ is $\\carolannpeacock.comcalO(n \\, \\logn)$ without understand theorem , if $T(1)=\\carolannpeacock.comcalO(1)$?

How have the right to I continue from here?

$T(n) = 2T(n/2) + n,$$T(n) = 4T(n/4) + 2n,$$T(n) =$$...,$$T(n) = 2^kT(n/2^k) + kn.$


\"*\"

\"*\"

The # that recurrences until $T(\\fracn2) = T(1)$ is $log_2(n)$ so just substitute $k$ through $log_2(n)$ native $T(n) = 2^kT(\\fracn2^k)+kn$ to acquire a simplified result.

As for just how the # that recurrence is $log_2(n)$, where each recurrence halves $n$, keep in mind that this has actually an inverse partnership to copy $n$ at every recurrence:

Starting at 1, you require to double this $log_2(n)$ plenty of times in bespeak to acquire up to $n$: $1*2^log_2(n) = n$. Conversely, beginning at $n$, you need to halve this $log_2(n)$ many times in order to get down to 1: $\\fracn2^log_2(n) = 1$

This continues to be true because that the case where $T(n) = 2T(n/2) + O(n)$, i beg your pardon is valuable for such divide-and-conquer algorithm.

You are watching: T(n)=2t(n/2)+n


\"*\"

Note that$$\\fracT(n)n=\\fracT(n/2)n/2+1$$hence$$\\fracT(2^k)2^k=T(1)+k$$that is,$$T(2^k)\\in\\Theta(k\\,2^k).$$It appears that, in the paper definition of homework on intricacy of algorithms, the (rigorous) result above is considered to indicate (although, in the lack of some supplementary hypothesis, that does not) that$$T(n)\\in\\Theta(n\\,\\log n).$$


\"*\"

Use substitution

$$S(n) = T(2^n) =2T(\\frac2^n2)+2^n = 2T(2^n-1)+2^n = 2S(n-1)+2^n$$

So you need to solve recursion

$$S(n) = 2S(n-1) + 2^n,$$

or

$$S(n)-2S(n-1) = 2^n.$$

So,

$$S(n-1) - 2S(n-2) = 2^n-1$$

and

$$2S(n-1) - 4S(n-2) = 2^n$$

So,

$$S(n) - 2S(n-1) = 2S(n-1)-4S(n-2)$$

or

$$S(n) - 4S(n-1)+4S(n-1) = 0.$$

Characteristic equation for the recursion is

$$x^2-4x+4 = 0,$$

or

$$(x-2)^2 = 0.$$

This equation has troots $x_1 = x_2 = 2$, so general solution because that it is

$$S(n) = C_12^n + C_2n2^n.$$

At the finish you turn earlier to $T(n)$.

$$T(n) = S(\\lg n) = C_1n + C_2n\\lg n$$

From the critical equation you deserve to conclude the

$$T(n) = \\Theta(n\\lg n).$$


\"*\"

You deserve to assume the inductive hypothesis that $T(n)=Cn + nlogn$, whereby $T(1)=C$ and also then proceed to prove this an outcome easily by induction. Then, the result is clear. Keep in mind that this proves the an outcome only because that powers the two yet you have the right to use asymptotics come generalise this an outcome for all $n$.


Thanks for contributing solution to carolannpeacock.comematics stack Exchange!

Please be certain to answer the question. Administer details and share her research!

But avoid

Asking because that help, clarification, or responding to various other answers.Making statements based upon opinion; earlier them increase with referrals or an individual experience.

Use carolannpeacock.comJax to format equations. Carolannpeacock.comJax reference.

See more: Compare Samsung Galaxy S7 Active Vs S8 Active Vs Galaxy S8 Active

To learn more, check out our advice on writing an excellent answers.


write-up Your price Discard

By click “Post your Answer”, you agree come our regards to service, privacy policy and also cookie policy


Not the prize you're looking for? Browse various other questions tagged asymptotics recurrence-relations or ask your very own question.


site style / logo design © 2021 stack Exchange Inc; user contributions license is granted under cc by-sa. Rev2021.10.14.40465


your privacy

By click “Accept all cookies”, girlfriend agree stack Exchange deserve to store cookie on your an equipment and disclose information in accordance through our Cookie Policy.