How to solve $T(n) = T(2n/3) + lg^2 n$ by substitution?
$begingroup$
My solution through substitution is as follows:
$$T(n) = T(2n/3) + lg^2 (n)$$
$$T(2n/3) = T(4n/9) + lg^2 (2n/3)$$
$$T(4n/9) = T(8n/27) + lg^2 (4n/9)$$
And so on...
But my actual problem is how can I calculate the below step which cause to obtain order of the above expression:
$$lg^2 left(ncdot(2/3)ncdot(2/3)^2ncdot(2/3)^3ncdotsright).$$
Also I know the order is $theta(lg^3n)$.
Thanks!
notation asymptotics recursion substitution
$endgroup$
add a comment |
$begingroup$
My solution through substitution is as follows:
$$T(n) = T(2n/3) + lg^2 (n)$$
$$T(2n/3) = T(4n/9) + lg^2 (2n/3)$$
$$T(4n/9) = T(8n/27) + lg^2 (4n/9)$$
And so on...
But my actual problem is how can I calculate the below step which cause to obtain order of the above expression:
$$lg^2 left(ncdot(2/3)ncdot(2/3)^2ncdot(2/3)^3ncdotsright).$$
Also I know the order is $theta(lg^3n)$.
Thanks!
notation asymptotics recursion substitution
$endgroup$
$begingroup$
Hi, can you please add some brackets at the first 3 rows for the logarithms? It is abit confusing, but I guess it should be: $lg^2(2n/3)$. Also are you sure that the second row is $T(n)$ instead of $T(2n/3)$?
$endgroup$
– Zacky
Dec 25 '18 at 13:11
$begingroup$
@Zacky Hi! I've added those parentheses and You're right it's T(2n/3) instead of T(n).My bad!
$endgroup$
– Alireza_T
Dec 25 '18 at 13:24
$begingroup$
Also how do you end the recursion, I mean how did your teacher tought you to write afterwards $T(n)$ as a complete sum? I can answer you by how I've learnt, but it might differ.
$endgroup$
– Zacky
Dec 25 '18 at 13:26
$begingroup$
@Zacky My initial thought for this specific example is to reach T(1)! It's kinda like recursion tree problems to me with one branch!
$endgroup$
– Alireza_T
Dec 25 '18 at 13:31
add a comment |
$begingroup$
My solution through substitution is as follows:
$$T(n) = T(2n/3) + lg^2 (n)$$
$$T(2n/3) = T(4n/9) + lg^2 (2n/3)$$
$$T(4n/9) = T(8n/27) + lg^2 (4n/9)$$
And so on...
But my actual problem is how can I calculate the below step which cause to obtain order of the above expression:
$$lg^2 left(ncdot(2/3)ncdot(2/3)^2ncdot(2/3)^3ncdotsright).$$
Also I know the order is $theta(lg^3n)$.
Thanks!
notation asymptotics recursion substitution
$endgroup$
My solution through substitution is as follows:
$$T(n) = T(2n/3) + lg^2 (n)$$
$$T(2n/3) = T(4n/9) + lg^2 (2n/3)$$
$$T(4n/9) = T(8n/27) + lg^2 (4n/9)$$
And so on...
But my actual problem is how can I calculate the below step which cause to obtain order of the above expression:
$$lg^2 left(ncdot(2/3)ncdot(2/3)^2ncdot(2/3)^3ncdotsright).$$
Also I know the order is $theta(lg^3n)$.
Thanks!
notation asymptotics recursion substitution
notation asymptotics recursion substitution
edited Dec 26 '18 at 9:47
Alireza_T
asked Dec 25 '18 at 13:03
Alireza_TAlireza_T
83
83
$begingroup$
Hi, can you please add some brackets at the first 3 rows for the logarithms? It is abit confusing, but I guess it should be: $lg^2(2n/3)$. Also are you sure that the second row is $T(n)$ instead of $T(2n/3)$?
$endgroup$
– Zacky
Dec 25 '18 at 13:11
$begingroup$
@Zacky Hi! I've added those parentheses and You're right it's T(2n/3) instead of T(n).My bad!
$endgroup$
– Alireza_T
Dec 25 '18 at 13:24
$begingroup$
Also how do you end the recursion, I mean how did your teacher tought you to write afterwards $T(n)$ as a complete sum? I can answer you by how I've learnt, but it might differ.
$endgroup$
– Zacky
Dec 25 '18 at 13:26
$begingroup$
@Zacky My initial thought for this specific example is to reach T(1)! It's kinda like recursion tree problems to me with one branch!
$endgroup$
– Alireza_T
Dec 25 '18 at 13:31
add a comment |
$begingroup$
Hi, can you please add some brackets at the first 3 rows for the logarithms? It is abit confusing, but I guess it should be: $lg^2(2n/3)$. Also are you sure that the second row is $T(n)$ instead of $T(2n/3)$?
$endgroup$
– Zacky
Dec 25 '18 at 13:11
$begingroup$
@Zacky Hi! I've added those parentheses and You're right it's T(2n/3) instead of T(n).My bad!
$endgroup$
– Alireza_T
Dec 25 '18 at 13:24
$begingroup$
Also how do you end the recursion, I mean how did your teacher tought you to write afterwards $T(n)$ as a complete sum? I can answer you by how I've learnt, but it might differ.
$endgroup$
– Zacky
Dec 25 '18 at 13:26
$begingroup$
@Zacky My initial thought for this specific example is to reach T(1)! It's kinda like recursion tree problems to me with one branch!
$endgroup$
– Alireza_T
Dec 25 '18 at 13:31
$begingroup$
Hi, can you please add some brackets at the first 3 rows for the logarithms? It is abit confusing, but I guess it should be: $lg^2(2n/3)$. Also are you sure that the second row is $T(n)$ instead of $T(2n/3)$?
$endgroup$
– Zacky
Dec 25 '18 at 13:11
$begingroup$
Hi, can you please add some brackets at the first 3 rows for the logarithms? It is abit confusing, but I guess it should be: $lg^2(2n/3)$. Also are you sure that the second row is $T(n)$ instead of $T(2n/3)$?
$endgroup$
– Zacky
Dec 25 '18 at 13:11
$begingroup$
@Zacky Hi! I've added those parentheses and You're right it's T(2n/3) instead of T(n).My bad!
$endgroup$
– Alireza_T
Dec 25 '18 at 13:24
$begingroup$
@Zacky Hi! I've added those parentheses and You're right it's T(2n/3) instead of T(n).My bad!
$endgroup$
– Alireza_T
Dec 25 '18 at 13:24
$begingroup$
Also how do you end the recursion, I mean how did your teacher tought you to write afterwards $T(n)$ as a complete sum? I can answer you by how I've learnt, but it might differ.
$endgroup$
– Zacky
Dec 25 '18 at 13:26
$begingroup$
Also how do you end the recursion, I mean how did your teacher tought you to write afterwards $T(n)$ as a complete sum? I can answer you by how I've learnt, but it might differ.
$endgroup$
– Zacky
Dec 25 '18 at 13:26
$begingroup$
@Zacky My initial thought for this specific example is to reach T(1)! It's kinda like recursion tree problems to me with one branch!
$endgroup$
– Alireza_T
Dec 25 '18 at 13:31
$begingroup$
@Zacky My initial thought for this specific example is to reach T(1)! It's kinda like recursion tree problems to me with one branch!
$endgroup$
– Alireza_T
Dec 25 '18 at 13:31
add a comment |
2 Answers
2
active
oldest
votes
$begingroup$
$$T(n)=Tleft(frac{2n}{3}right)+lg^2 n$$
$$Tleft(frac{2n}{3}right)=Tleft(frac{2cdotfrac{2n}{3}}{3}right)+lg^2left(frac{2n}{3}right)=Tleft(frac{2^2n}{3^2}right)+lg^2left(frac{2n}{3}right)$$
$$Tleft(frac{2^2n}{3^2}right)=Tleft(frac{2^3n}{3^3}right)+lg^2left(frac{2^2n}{3^2}right)$$
$$dots Tleft(frac{2^{q-1}cdot n}{3^{q-1}}right)= Tleft(frac{2^{q}cdot n}{3^{q}}right)+lg^2 left(frac{2^{q-1}cdot n}{3^{q-1}}right) $$
Now in order to obtain $T(1)$ we consider the limit condition:
$$Tleft(frac{2^qcdot n}{3^q}right)=T(1)Rightarrow left(frac23right)^qn=1Rightarrow n=left(frac{3}{2}right)^qRightarrow log_{frac32}n=q$$
$$Rightarrow T(n)=T(1)+lg^2 n+lg^2left(frac{2n}{3}right)+dots +lg^2 left(frac{2^{q-1}cdot n}{3^{q-1}}right) $$
Now we write the above as a sum. Also the time complexity of $T(1)$ is just $Theta(1)$.
$$T(n)=Theta(1)+sum_{k=0}^{q-1}lg^2left(left(frac{2}{3}right)^knright),quad q=log_{frac32}n$$
Now we have using some basic algebra and properties of the logarithms: $$left(lgleft(left(frac23right)^k cdot nright)right)^2=left(lgleft(frac23right)^k+ lg nright)^2=left(klgleft(frac23right)+ lg nright)^2=$$
$$=k^2 lg^2left(frac23right)+2klgleft(frac23right)lg n+lg^2n$$
$$Rightarrow T(n)=Theta(1)+lg^2left(frac23right)sum_{k=0}^{q-1}k^2+2lgleft(frac23right)lg nsum_{k=0}^{q-1} k +lg^2nsum_{k=0}^{q-1}1$$
$$=Theta(1)+lg^2left(frac23right)frac{(q-1)q(2q-1)}{6}+2lgleft(frac23right)lg nfrac{(q-1)q}{2}+lg^2 n (q-1)$$
Now note that $ displaystyle{q=log_{frac23}{n}=frac{lg n}{lgfrac23}},$ and to obtain the time complexity constants don't matter.
$$T(n)= Theta(1)+c_1 (lg n-1)lg n(2lg n-1)+c_2 lg ncdot (lg n-1)lg n +c_3 lg^2ncdot (lg n-1) $$
$$T(n)=Theta(1)+c_1Theta(lg^3 n)+c_2Theta(lg^3 n)+c_3Theta(lg^3n)=Theta(lg^ 3 n)$$
$endgroup$
$begingroup$
Well, thanks a lot.That's exactly what I'm looking for.
$endgroup$
– Alireza_T
Dec 25 '18 at 14:12
$begingroup$
I'm glad that I could help.
$endgroup$
– Zacky
Dec 25 '18 at 14:15
add a comment |
$begingroup$
Look at the generaliyzed recurrence $Tleft(xright)=Tleft(ccdot xright)+left(log_{10}xright)^{2}$ with $0<c<1$.
First of all, $text{Dom}Tleft(xright)subseteqmathbb{R}^{+}$ as $log_{10}x$ existst and $text{Dom}log_{10}xsubseteqmathbb{R}^{+}$. Therefore, define $$U(x)=Tleft(10^{x}right)qquadlog_{10}c=alpha<0$$
Then:
$$Tleft(xright)=Uleft(log_{10}xright)qquad Tleft(cxright)=Uleft(alpha+log_{10}xright)$$
Therefore, for U, the functional equation becomes:
$$Uleft(vright)=Uleft(alpha+vright)+v^{2}$$
Let $v_{1}=-kalpha+beta$ with $betain(0,-alpha]$ and $k$ integer, then
$$Uleft(beta-kalpharight)=Uleft(beta-left(k-1right)alpharight)+left(beta-kalpharight)^{2}$$
Let $v_{2}=kalpha+beta$ with $betain(0,-alpha]$ and $k$ integer, then
$$Uleft(beta+kalpharight)=Uleft(beta+left(k-1right)alpharight)-left(beta-left(k-1right)alpharight)^{2}$$
$$U(v_{1})=sum_{i=1}^{k}left(beta-ialpharight)^{2}+Uleft(betaright)=beta^{2}k-alphabeta k(k+1)+frac{alpha^{2}}{6}k(k+1)(2k+1)+Uleft(betaright)$$
$$U(v_{2})=-sum_{i=0}^{k-1}left(beta-ialpharight)^{2}+Uleft(betaright)=beta^{2}k-alphabeta k(k+1)+frac{alpha^{2}}{6}k(k+1)(2k+1)+Uleft(betaright)$$
$$Uleft(beta-kalpharight)=beta^{2}k-alphabeta k(k+1)+frac{alpha^{2}}{6}k(k+1)(2k+1)+Uleft(betaright)$$
$$Uleft(beta+kalpharight)=-beta^{2}k+alphabeta k(k+1)-frac{alpha^{2}}{6}k(k-1)(2k-1)+Uleft(betaright)$$
Hence, we can define any function $U$ on $(0,-alpha]$ and then extend it with the above formula. Implying $T $ from this is straightforward via the relation $U(x)=Tleft(10^{x}right)$. So in your case, you can have any function $f(x)$ on $left(0,log_{10}frac{2}{3} right]$, extend via the previously decribed relations, and set the function $T$ via $T(x)=U(log_{10}x)$
$endgroup$
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "69"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3052090%2fhow-to-solve-tn-t2n-3-lg2-n-by-substitution%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
$$T(n)=Tleft(frac{2n}{3}right)+lg^2 n$$
$$Tleft(frac{2n}{3}right)=Tleft(frac{2cdotfrac{2n}{3}}{3}right)+lg^2left(frac{2n}{3}right)=Tleft(frac{2^2n}{3^2}right)+lg^2left(frac{2n}{3}right)$$
$$Tleft(frac{2^2n}{3^2}right)=Tleft(frac{2^3n}{3^3}right)+lg^2left(frac{2^2n}{3^2}right)$$
$$dots Tleft(frac{2^{q-1}cdot n}{3^{q-1}}right)= Tleft(frac{2^{q}cdot n}{3^{q}}right)+lg^2 left(frac{2^{q-1}cdot n}{3^{q-1}}right) $$
Now in order to obtain $T(1)$ we consider the limit condition:
$$Tleft(frac{2^qcdot n}{3^q}right)=T(1)Rightarrow left(frac23right)^qn=1Rightarrow n=left(frac{3}{2}right)^qRightarrow log_{frac32}n=q$$
$$Rightarrow T(n)=T(1)+lg^2 n+lg^2left(frac{2n}{3}right)+dots +lg^2 left(frac{2^{q-1}cdot n}{3^{q-1}}right) $$
Now we write the above as a sum. Also the time complexity of $T(1)$ is just $Theta(1)$.
$$T(n)=Theta(1)+sum_{k=0}^{q-1}lg^2left(left(frac{2}{3}right)^knright),quad q=log_{frac32}n$$
Now we have using some basic algebra and properties of the logarithms: $$left(lgleft(left(frac23right)^k cdot nright)right)^2=left(lgleft(frac23right)^k+ lg nright)^2=left(klgleft(frac23right)+ lg nright)^2=$$
$$=k^2 lg^2left(frac23right)+2klgleft(frac23right)lg n+lg^2n$$
$$Rightarrow T(n)=Theta(1)+lg^2left(frac23right)sum_{k=0}^{q-1}k^2+2lgleft(frac23right)lg nsum_{k=0}^{q-1} k +lg^2nsum_{k=0}^{q-1}1$$
$$=Theta(1)+lg^2left(frac23right)frac{(q-1)q(2q-1)}{6}+2lgleft(frac23right)lg nfrac{(q-1)q}{2}+lg^2 n (q-1)$$
Now note that $ displaystyle{q=log_{frac23}{n}=frac{lg n}{lgfrac23}},$ and to obtain the time complexity constants don't matter.
$$T(n)= Theta(1)+c_1 (lg n-1)lg n(2lg n-1)+c_2 lg ncdot (lg n-1)lg n +c_3 lg^2ncdot (lg n-1) $$
$$T(n)=Theta(1)+c_1Theta(lg^3 n)+c_2Theta(lg^3 n)+c_3Theta(lg^3n)=Theta(lg^ 3 n)$$
$endgroup$
$begingroup$
Well, thanks a lot.That's exactly what I'm looking for.
$endgroup$
– Alireza_T
Dec 25 '18 at 14:12
$begingroup$
I'm glad that I could help.
$endgroup$
– Zacky
Dec 25 '18 at 14:15
add a comment |
$begingroup$
$$T(n)=Tleft(frac{2n}{3}right)+lg^2 n$$
$$Tleft(frac{2n}{3}right)=Tleft(frac{2cdotfrac{2n}{3}}{3}right)+lg^2left(frac{2n}{3}right)=Tleft(frac{2^2n}{3^2}right)+lg^2left(frac{2n}{3}right)$$
$$Tleft(frac{2^2n}{3^2}right)=Tleft(frac{2^3n}{3^3}right)+lg^2left(frac{2^2n}{3^2}right)$$
$$dots Tleft(frac{2^{q-1}cdot n}{3^{q-1}}right)= Tleft(frac{2^{q}cdot n}{3^{q}}right)+lg^2 left(frac{2^{q-1}cdot n}{3^{q-1}}right) $$
Now in order to obtain $T(1)$ we consider the limit condition:
$$Tleft(frac{2^qcdot n}{3^q}right)=T(1)Rightarrow left(frac23right)^qn=1Rightarrow n=left(frac{3}{2}right)^qRightarrow log_{frac32}n=q$$
$$Rightarrow T(n)=T(1)+lg^2 n+lg^2left(frac{2n}{3}right)+dots +lg^2 left(frac{2^{q-1}cdot n}{3^{q-1}}right) $$
Now we write the above as a sum. Also the time complexity of $T(1)$ is just $Theta(1)$.
$$T(n)=Theta(1)+sum_{k=0}^{q-1}lg^2left(left(frac{2}{3}right)^knright),quad q=log_{frac32}n$$
Now we have using some basic algebra and properties of the logarithms: $$left(lgleft(left(frac23right)^k cdot nright)right)^2=left(lgleft(frac23right)^k+ lg nright)^2=left(klgleft(frac23right)+ lg nright)^2=$$
$$=k^2 lg^2left(frac23right)+2klgleft(frac23right)lg n+lg^2n$$
$$Rightarrow T(n)=Theta(1)+lg^2left(frac23right)sum_{k=0}^{q-1}k^2+2lgleft(frac23right)lg nsum_{k=0}^{q-1} k +lg^2nsum_{k=0}^{q-1}1$$
$$=Theta(1)+lg^2left(frac23right)frac{(q-1)q(2q-1)}{6}+2lgleft(frac23right)lg nfrac{(q-1)q}{2}+lg^2 n (q-1)$$
Now note that $ displaystyle{q=log_{frac23}{n}=frac{lg n}{lgfrac23}},$ and to obtain the time complexity constants don't matter.
$$T(n)= Theta(1)+c_1 (lg n-1)lg n(2lg n-1)+c_2 lg ncdot (lg n-1)lg n +c_3 lg^2ncdot (lg n-1) $$
$$T(n)=Theta(1)+c_1Theta(lg^3 n)+c_2Theta(lg^3 n)+c_3Theta(lg^3n)=Theta(lg^ 3 n)$$
$endgroup$
$begingroup$
Well, thanks a lot.That's exactly what I'm looking for.
$endgroup$
– Alireza_T
Dec 25 '18 at 14:12
$begingroup$
I'm glad that I could help.
$endgroup$
– Zacky
Dec 25 '18 at 14:15
add a comment |
$begingroup$
$$T(n)=Tleft(frac{2n}{3}right)+lg^2 n$$
$$Tleft(frac{2n}{3}right)=Tleft(frac{2cdotfrac{2n}{3}}{3}right)+lg^2left(frac{2n}{3}right)=Tleft(frac{2^2n}{3^2}right)+lg^2left(frac{2n}{3}right)$$
$$Tleft(frac{2^2n}{3^2}right)=Tleft(frac{2^3n}{3^3}right)+lg^2left(frac{2^2n}{3^2}right)$$
$$dots Tleft(frac{2^{q-1}cdot n}{3^{q-1}}right)= Tleft(frac{2^{q}cdot n}{3^{q}}right)+lg^2 left(frac{2^{q-1}cdot n}{3^{q-1}}right) $$
Now in order to obtain $T(1)$ we consider the limit condition:
$$Tleft(frac{2^qcdot n}{3^q}right)=T(1)Rightarrow left(frac23right)^qn=1Rightarrow n=left(frac{3}{2}right)^qRightarrow log_{frac32}n=q$$
$$Rightarrow T(n)=T(1)+lg^2 n+lg^2left(frac{2n}{3}right)+dots +lg^2 left(frac{2^{q-1}cdot n}{3^{q-1}}right) $$
Now we write the above as a sum. Also the time complexity of $T(1)$ is just $Theta(1)$.
$$T(n)=Theta(1)+sum_{k=0}^{q-1}lg^2left(left(frac{2}{3}right)^knright),quad q=log_{frac32}n$$
Now we have using some basic algebra and properties of the logarithms: $$left(lgleft(left(frac23right)^k cdot nright)right)^2=left(lgleft(frac23right)^k+ lg nright)^2=left(klgleft(frac23right)+ lg nright)^2=$$
$$=k^2 lg^2left(frac23right)+2klgleft(frac23right)lg n+lg^2n$$
$$Rightarrow T(n)=Theta(1)+lg^2left(frac23right)sum_{k=0}^{q-1}k^2+2lgleft(frac23right)lg nsum_{k=0}^{q-1} k +lg^2nsum_{k=0}^{q-1}1$$
$$=Theta(1)+lg^2left(frac23right)frac{(q-1)q(2q-1)}{6}+2lgleft(frac23right)lg nfrac{(q-1)q}{2}+lg^2 n (q-1)$$
Now note that $ displaystyle{q=log_{frac23}{n}=frac{lg n}{lgfrac23}},$ and to obtain the time complexity constants don't matter.
$$T(n)= Theta(1)+c_1 (lg n-1)lg n(2lg n-1)+c_2 lg ncdot (lg n-1)lg n +c_3 lg^2ncdot (lg n-1) $$
$$T(n)=Theta(1)+c_1Theta(lg^3 n)+c_2Theta(lg^3 n)+c_3Theta(lg^3n)=Theta(lg^ 3 n)$$
$endgroup$
$$T(n)=Tleft(frac{2n}{3}right)+lg^2 n$$
$$Tleft(frac{2n}{3}right)=Tleft(frac{2cdotfrac{2n}{3}}{3}right)+lg^2left(frac{2n}{3}right)=Tleft(frac{2^2n}{3^2}right)+lg^2left(frac{2n}{3}right)$$
$$Tleft(frac{2^2n}{3^2}right)=Tleft(frac{2^3n}{3^3}right)+lg^2left(frac{2^2n}{3^2}right)$$
$$dots Tleft(frac{2^{q-1}cdot n}{3^{q-1}}right)= Tleft(frac{2^{q}cdot n}{3^{q}}right)+lg^2 left(frac{2^{q-1}cdot n}{3^{q-1}}right) $$
Now in order to obtain $T(1)$ we consider the limit condition:
$$Tleft(frac{2^qcdot n}{3^q}right)=T(1)Rightarrow left(frac23right)^qn=1Rightarrow n=left(frac{3}{2}right)^qRightarrow log_{frac32}n=q$$
$$Rightarrow T(n)=T(1)+lg^2 n+lg^2left(frac{2n}{3}right)+dots +lg^2 left(frac{2^{q-1}cdot n}{3^{q-1}}right) $$
Now we write the above as a sum. Also the time complexity of $T(1)$ is just $Theta(1)$.
$$T(n)=Theta(1)+sum_{k=0}^{q-1}lg^2left(left(frac{2}{3}right)^knright),quad q=log_{frac32}n$$
Now we have using some basic algebra and properties of the logarithms: $$left(lgleft(left(frac23right)^k cdot nright)right)^2=left(lgleft(frac23right)^k+ lg nright)^2=left(klgleft(frac23right)+ lg nright)^2=$$
$$=k^2 lg^2left(frac23right)+2klgleft(frac23right)lg n+lg^2n$$
$$Rightarrow T(n)=Theta(1)+lg^2left(frac23right)sum_{k=0}^{q-1}k^2+2lgleft(frac23right)lg nsum_{k=0}^{q-1} k +lg^2nsum_{k=0}^{q-1}1$$
$$=Theta(1)+lg^2left(frac23right)frac{(q-1)q(2q-1)}{6}+2lgleft(frac23right)lg nfrac{(q-1)q}{2}+lg^2 n (q-1)$$
Now note that $ displaystyle{q=log_{frac23}{n}=frac{lg n}{lgfrac23}},$ and to obtain the time complexity constants don't matter.
$$T(n)= Theta(1)+c_1 (lg n-1)lg n(2lg n-1)+c_2 lg ncdot (lg n-1)lg n +c_3 lg^2ncdot (lg n-1) $$
$$T(n)=Theta(1)+c_1Theta(lg^3 n)+c_2Theta(lg^3 n)+c_3Theta(lg^3n)=Theta(lg^ 3 n)$$
edited Dec 26 '18 at 12:13
answered Dec 25 '18 at 14:07
ZackyZacky
7,62011061
7,62011061
$begingroup$
Well, thanks a lot.That's exactly what I'm looking for.
$endgroup$
– Alireza_T
Dec 25 '18 at 14:12
$begingroup$
I'm glad that I could help.
$endgroup$
– Zacky
Dec 25 '18 at 14:15
add a comment |
$begingroup$
Well, thanks a lot.That's exactly what I'm looking for.
$endgroup$
– Alireza_T
Dec 25 '18 at 14:12
$begingroup$
I'm glad that I could help.
$endgroup$
– Zacky
Dec 25 '18 at 14:15
$begingroup$
Well, thanks a lot.That's exactly what I'm looking for.
$endgroup$
– Alireza_T
Dec 25 '18 at 14:12
$begingroup$
Well, thanks a lot.That's exactly what I'm looking for.
$endgroup$
– Alireza_T
Dec 25 '18 at 14:12
$begingroup$
I'm glad that I could help.
$endgroup$
– Zacky
Dec 25 '18 at 14:15
$begingroup$
I'm glad that I could help.
$endgroup$
– Zacky
Dec 25 '18 at 14:15
add a comment |
$begingroup$
Look at the generaliyzed recurrence $Tleft(xright)=Tleft(ccdot xright)+left(log_{10}xright)^{2}$ with $0<c<1$.
First of all, $text{Dom}Tleft(xright)subseteqmathbb{R}^{+}$ as $log_{10}x$ existst and $text{Dom}log_{10}xsubseteqmathbb{R}^{+}$. Therefore, define $$U(x)=Tleft(10^{x}right)qquadlog_{10}c=alpha<0$$
Then:
$$Tleft(xright)=Uleft(log_{10}xright)qquad Tleft(cxright)=Uleft(alpha+log_{10}xright)$$
Therefore, for U, the functional equation becomes:
$$Uleft(vright)=Uleft(alpha+vright)+v^{2}$$
Let $v_{1}=-kalpha+beta$ with $betain(0,-alpha]$ and $k$ integer, then
$$Uleft(beta-kalpharight)=Uleft(beta-left(k-1right)alpharight)+left(beta-kalpharight)^{2}$$
Let $v_{2}=kalpha+beta$ with $betain(0,-alpha]$ and $k$ integer, then
$$Uleft(beta+kalpharight)=Uleft(beta+left(k-1right)alpharight)-left(beta-left(k-1right)alpharight)^{2}$$
$$U(v_{1})=sum_{i=1}^{k}left(beta-ialpharight)^{2}+Uleft(betaright)=beta^{2}k-alphabeta k(k+1)+frac{alpha^{2}}{6}k(k+1)(2k+1)+Uleft(betaright)$$
$$U(v_{2})=-sum_{i=0}^{k-1}left(beta-ialpharight)^{2}+Uleft(betaright)=beta^{2}k-alphabeta k(k+1)+frac{alpha^{2}}{6}k(k+1)(2k+1)+Uleft(betaright)$$
$$Uleft(beta-kalpharight)=beta^{2}k-alphabeta k(k+1)+frac{alpha^{2}}{6}k(k+1)(2k+1)+Uleft(betaright)$$
$$Uleft(beta+kalpharight)=-beta^{2}k+alphabeta k(k+1)-frac{alpha^{2}}{6}k(k-1)(2k-1)+Uleft(betaright)$$
Hence, we can define any function $U$ on $(0,-alpha]$ and then extend it with the above formula. Implying $T $ from this is straightforward via the relation $U(x)=Tleft(10^{x}right)$. So in your case, you can have any function $f(x)$ on $left(0,log_{10}frac{2}{3} right]$, extend via the previously decribed relations, and set the function $T$ via $T(x)=U(log_{10}x)$
$endgroup$
add a comment |
$begingroup$
Look at the generaliyzed recurrence $Tleft(xright)=Tleft(ccdot xright)+left(log_{10}xright)^{2}$ with $0<c<1$.
First of all, $text{Dom}Tleft(xright)subseteqmathbb{R}^{+}$ as $log_{10}x$ existst and $text{Dom}log_{10}xsubseteqmathbb{R}^{+}$. Therefore, define $$U(x)=Tleft(10^{x}right)qquadlog_{10}c=alpha<0$$
Then:
$$Tleft(xright)=Uleft(log_{10}xright)qquad Tleft(cxright)=Uleft(alpha+log_{10}xright)$$
Therefore, for U, the functional equation becomes:
$$Uleft(vright)=Uleft(alpha+vright)+v^{2}$$
Let $v_{1}=-kalpha+beta$ with $betain(0,-alpha]$ and $k$ integer, then
$$Uleft(beta-kalpharight)=Uleft(beta-left(k-1right)alpharight)+left(beta-kalpharight)^{2}$$
Let $v_{2}=kalpha+beta$ with $betain(0,-alpha]$ and $k$ integer, then
$$Uleft(beta+kalpharight)=Uleft(beta+left(k-1right)alpharight)-left(beta-left(k-1right)alpharight)^{2}$$
$$U(v_{1})=sum_{i=1}^{k}left(beta-ialpharight)^{2}+Uleft(betaright)=beta^{2}k-alphabeta k(k+1)+frac{alpha^{2}}{6}k(k+1)(2k+1)+Uleft(betaright)$$
$$U(v_{2})=-sum_{i=0}^{k-1}left(beta-ialpharight)^{2}+Uleft(betaright)=beta^{2}k-alphabeta k(k+1)+frac{alpha^{2}}{6}k(k+1)(2k+1)+Uleft(betaright)$$
$$Uleft(beta-kalpharight)=beta^{2}k-alphabeta k(k+1)+frac{alpha^{2}}{6}k(k+1)(2k+1)+Uleft(betaright)$$
$$Uleft(beta+kalpharight)=-beta^{2}k+alphabeta k(k+1)-frac{alpha^{2}}{6}k(k-1)(2k-1)+Uleft(betaright)$$
Hence, we can define any function $U$ on $(0,-alpha]$ and then extend it with the above formula. Implying $T $ from this is straightforward via the relation $U(x)=Tleft(10^{x}right)$. So in your case, you can have any function $f(x)$ on $left(0,log_{10}frac{2}{3} right]$, extend via the previously decribed relations, and set the function $T$ via $T(x)=U(log_{10}x)$
$endgroup$
add a comment |
$begingroup$
Look at the generaliyzed recurrence $Tleft(xright)=Tleft(ccdot xright)+left(log_{10}xright)^{2}$ with $0<c<1$.
First of all, $text{Dom}Tleft(xright)subseteqmathbb{R}^{+}$ as $log_{10}x$ existst and $text{Dom}log_{10}xsubseteqmathbb{R}^{+}$. Therefore, define $$U(x)=Tleft(10^{x}right)qquadlog_{10}c=alpha<0$$
Then:
$$Tleft(xright)=Uleft(log_{10}xright)qquad Tleft(cxright)=Uleft(alpha+log_{10}xright)$$
Therefore, for U, the functional equation becomes:
$$Uleft(vright)=Uleft(alpha+vright)+v^{2}$$
Let $v_{1}=-kalpha+beta$ with $betain(0,-alpha]$ and $k$ integer, then
$$Uleft(beta-kalpharight)=Uleft(beta-left(k-1right)alpharight)+left(beta-kalpharight)^{2}$$
Let $v_{2}=kalpha+beta$ with $betain(0,-alpha]$ and $k$ integer, then
$$Uleft(beta+kalpharight)=Uleft(beta+left(k-1right)alpharight)-left(beta-left(k-1right)alpharight)^{2}$$
$$U(v_{1})=sum_{i=1}^{k}left(beta-ialpharight)^{2}+Uleft(betaright)=beta^{2}k-alphabeta k(k+1)+frac{alpha^{2}}{6}k(k+1)(2k+1)+Uleft(betaright)$$
$$U(v_{2})=-sum_{i=0}^{k-1}left(beta-ialpharight)^{2}+Uleft(betaright)=beta^{2}k-alphabeta k(k+1)+frac{alpha^{2}}{6}k(k+1)(2k+1)+Uleft(betaright)$$
$$Uleft(beta-kalpharight)=beta^{2}k-alphabeta k(k+1)+frac{alpha^{2}}{6}k(k+1)(2k+1)+Uleft(betaright)$$
$$Uleft(beta+kalpharight)=-beta^{2}k+alphabeta k(k+1)-frac{alpha^{2}}{6}k(k-1)(2k-1)+Uleft(betaright)$$
Hence, we can define any function $U$ on $(0,-alpha]$ and then extend it with the above formula. Implying $T $ from this is straightforward via the relation $U(x)=Tleft(10^{x}right)$. So in your case, you can have any function $f(x)$ on $left(0,log_{10}frac{2}{3} right]$, extend via the previously decribed relations, and set the function $T$ via $T(x)=U(log_{10}x)$
$endgroup$
Look at the generaliyzed recurrence $Tleft(xright)=Tleft(ccdot xright)+left(log_{10}xright)^{2}$ with $0<c<1$.
First of all, $text{Dom}Tleft(xright)subseteqmathbb{R}^{+}$ as $log_{10}x$ existst and $text{Dom}log_{10}xsubseteqmathbb{R}^{+}$. Therefore, define $$U(x)=Tleft(10^{x}right)qquadlog_{10}c=alpha<0$$
Then:
$$Tleft(xright)=Uleft(log_{10}xright)qquad Tleft(cxright)=Uleft(alpha+log_{10}xright)$$
Therefore, for U, the functional equation becomes:
$$Uleft(vright)=Uleft(alpha+vright)+v^{2}$$
Let $v_{1}=-kalpha+beta$ with $betain(0,-alpha]$ and $k$ integer, then
$$Uleft(beta-kalpharight)=Uleft(beta-left(k-1right)alpharight)+left(beta-kalpharight)^{2}$$
Let $v_{2}=kalpha+beta$ with $betain(0,-alpha]$ and $k$ integer, then
$$Uleft(beta+kalpharight)=Uleft(beta+left(k-1right)alpharight)-left(beta-left(k-1right)alpharight)^{2}$$
$$U(v_{1})=sum_{i=1}^{k}left(beta-ialpharight)^{2}+Uleft(betaright)=beta^{2}k-alphabeta k(k+1)+frac{alpha^{2}}{6}k(k+1)(2k+1)+Uleft(betaright)$$
$$U(v_{2})=-sum_{i=0}^{k-1}left(beta-ialpharight)^{2}+Uleft(betaright)=beta^{2}k-alphabeta k(k+1)+frac{alpha^{2}}{6}k(k+1)(2k+1)+Uleft(betaright)$$
$$Uleft(beta-kalpharight)=beta^{2}k-alphabeta k(k+1)+frac{alpha^{2}}{6}k(k+1)(2k+1)+Uleft(betaright)$$
$$Uleft(beta+kalpharight)=-beta^{2}k+alphabeta k(k+1)-frac{alpha^{2}}{6}k(k-1)(2k-1)+Uleft(betaright)$$
Hence, we can define any function $U$ on $(0,-alpha]$ and then extend it with the above formula. Implying $T $ from this is straightforward via the relation $U(x)=Tleft(10^{x}right)$. So in your case, you can have any function $f(x)$ on $left(0,log_{10}frac{2}{3} right]$, extend via the previously decribed relations, and set the function $T$ via $T(x)=U(log_{10}x)$
answered Dec 25 '18 at 13:55
Ákos SomogyiÁkos Somogyi
1,557417
1,557417
add a comment |
add a comment |
Thanks for contributing an answer to Mathematics Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3052090%2fhow-to-solve-tn-t2n-3-lg2-n-by-substitution%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
$begingroup$
Hi, can you please add some brackets at the first 3 rows for the logarithms? It is abit confusing, but I guess it should be: $lg^2(2n/3)$. Also are you sure that the second row is $T(n)$ instead of $T(2n/3)$?
$endgroup$
– Zacky
Dec 25 '18 at 13:11
$begingroup$
@Zacky Hi! I've added those parentheses and You're right it's T(2n/3) instead of T(n).My bad!
$endgroup$
– Alireza_T
Dec 25 '18 at 13:24
$begingroup$
Also how do you end the recursion, I mean how did your teacher tought you to write afterwards $T(n)$ as a complete sum? I can answer you by how I've learnt, but it might differ.
$endgroup$
– Zacky
Dec 25 '18 at 13:26
$begingroup$
@Zacky My initial thought for this specific example is to reach T(1)! It's kinda like recursion tree problems to me with one branch!
$endgroup$
– Alireza_T
Dec 25 '18 at 13:31