Solving a Recurrence Relation: T(n) = T(n-1) + n-1










1














I have been asked to solve that recurrence relation. I got the next solution: https://imgur.com/a/xWoTI40



So I decided to ask my teacher if it was right. He told me that it wasn't; and that this is the right solution: https://imgur.com/a/CGD0ta8



I'm totally clueless right now. The most I try to understand why mine is wrong; the most I think it's actually right.



Can somebody explain?










share|improve this question





















  • I'm voting to close this question as off-topic because it is a mathematics question, not a programming question.
    – Raymond Chen
    Nov 12 '18 at 21:50






  • 2




    You should ask to close this one as well @RaymondChen: stackoverflow.com/questions/2752977/how-to-solve-tn-tn-1-n
    – xFunkyTImes
    Nov 12 '18 at 21:55






  • 2




    The second solution seems incorrect to me, specially because for a large value of n it would be negative.
    – Ari
    Nov 12 '18 at 22:15










  • @xFunkyTimes Done, thanks.
    – Raymond Chen
    Nov 13 '18 at 2:10















1














I have been asked to solve that recurrence relation. I got the next solution: https://imgur.com/a/xWoTI40



So I decided to ask my teacher if it was right. He told me that it wasn't; and that this is the right solution: https://imgur.com/a/CGD0ta8



I'm totally clueless right now. The most I try to understand why mine is wrong; the most I think it's actually right.



Can somebody explain?










share|improve this question





















  • I'm voting to close this question as off-topic because it is a mathematics question, not a programming question.
    – Raymond Chen
    Nov 12 '18 at 21:50






  • 2




    You should ask to close this one as well @RaymondChen: stackoverflow.com/questions/2752977/how-to-solve-tn-tn-1-n
    – xFunkyTImes
    Nov 12 '18 at 21:55






  • 2




    The second solution seems incorrect to me, specially because for a large value of n it would be negative.
    – Ari
    Nov 12 '18 at 22:15










  • @xFunkyTimes Done, thanks.
    – Raymond Chen
    Nov 13 '18 at 2:10













1












1








1







I have been asked to solve that recurrence relation. I got the next solution: https://imgur.com/a/xWoTI40



So I decided to ask my teacher if it was right. He told me that it wasn't; and that this is the right solution: https://imgur.com/a/CGD0ta8



I'm totally clueless right now. The most I try to understand why mine is wrong; the most I think it's actually right.



Can somebody explain?










share|improve this question













I have been asked to solve that recurrence relation. I got the next solution: https://imgur.com/a/xWoTI40



So I decided to ask my teacher if it was right. He told me that it wasn't; and that this is the right solution: https://imgur.com/a/CGD0ta8



I'm totally clueless right now. The most I try to understand why mine is wrong; the most I think it's actually right.



Can somebody explain?







algorithm recurrence






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 12 '18 at 21:10









xFunkyTImes

928




928











  • I'm voting to close this question as off-topic because it is a mathematics question, not a programming question.
    – Raymond Chen
    Nov 12 '18 at 21:50






  • 2




    You should ask to close this one as well @RaymondChen: stackoverflow.com/questions/2752977/how-to-solve-tn-tn-1-n
    – xFunkyTImes
    Nov 12 '18 at 21:55






  • 2




    The second solution seems incorrect to me, specially because for a large value of n it would be negative.
    – Ari
    Nov 12 '18 at 22:15










  • @xFunkyTimes Done, thanks.
    – Raymond Chen
    Nov 13 '18 at 2:10
















  • I'm voting to close this question as off-topic because it is a mathematics question, not a programming question.
    – Raymond Chen
    Nov 12 '18 at 21:50






  • 2




    You should ask to close this one as well @RaymondChen: stackoverflow.com/questions/2752977/how-to-solve-tn-tn-1-n
    – xFunkyTImes
    Nov 12 '18 at 21:55






  • 2




    The second solution seems incorrect to me, specially because for a large value of n it would be negative.
    – Ari
    Nov 12 '18 at 22:15










  • @xFunkyTimes Done, thanks.
    – Raymond Chen
    Nov 13 '18 at 2:10















I'm voting to close this question as off-topic because it is a mathematics question, not a programming question.
– Raymond Chen
Nov 12 '18 at 21:50




I'm voting to close this question as off-topic because it is a mathematics question, not a programming question.
– Raymond Chen
Nov 12 '18 at 21:50




2




2




You should ask to close this one as well @RaymondChen: stackoverflow.com/questions/2752977/how-to-solve-tn-tn-1-n
– xFunkyTImes
Nov 12 '18 at 21:55




You should ask to close this one as well @RaymondChen: stackoverflow.com/questions/2752977/how-to-solve-tn-tn-1-n
– xFunkyTImes
Nov 12 '18 at 21:55




2




2




The second solution seems incorrect to me, specially because for a large value of n it would be negative.
– Ari
Nov 12 '18 at 22:15




The second solution seems incorrect to me, specially because for a large value of n it would be negative.
– Ari
Nov 12 '18 at 22:15












@xFunkyTimes Done, thanks.
– Raymond Chen
Nov 13 '18 at 2:10




@xFunkyTimes Done, thanks.
– Raymond Chen
Nov 13 '18 at 2:10












1 Answer
1






active

oldest

votes


















2














Your solution is correct. Here's a different approach with the same result:



t(1) = 0 (given)
t(2) = t(1) + 1 = 1
t(3) = t(2) + 2 = 1 + 2 = 3
t(4) = t(3) + 3 = 1 + 2 + 3 = 6
...
t(n) = 1 + 2 + ... + (n-1) = n * (n - 1) / 2 = Theta(n^2).


The teacher's solution is wrong after the second = sign. Here's what the teacher wrote:



t(n-1) + n - 1 = t(n-2) + n - 1 - 2


But actually the following is correct:



t(n-1) + n - 1 = ( t(n-2) + n - 2 ) + n - 1


which is actually exactly what you got. It appears that the teacher dropped an n term.



In fact, the teacher's solution ends with a dominant term of -n^2 which is clearly wrong, as t(n) >= 0 for all n >= 0.






share|improve this answer




















  • This is exactly what I was looking for. Thank you a lot @pkpnd
    – xFunkyTImes
    Nov 13 '18 at 8:30










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
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
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53270157%2fsolving-a-recurrence-relation-tn-tn-1-n-1%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














Your solution is correct. Here's a different approach with the same result:



t(1) = 0 (given)
t(2) = t(1) + 1 = 1
t(3) = t(2) + 2 = 1 + 2 = 3
t(4) = t(3) + 3 = 1 + 2 + 3 = 6
...
t(n) = 1 + 2 + ... + (n-1) = n * (n - 1) / 2 = Theta(n^2).


The teacher's solution is wrong after the second = sign. Here's what the teacher wrote:



t(n-1) + n - 1 = t(n-2) + n - 1 - 2


But actually the following is correct:



t(n-1) + n - 1 = ( t(n-2) + n - 2 ) + n - 1


which is actually exactly what you got. It appears that the teacher dropped an n term.



In fact, the teacher's solution ends with a dominant term of -n^2 which is clearly wrong, as t(n) >= 0 for all n >= 0.






share|improve this answer




















  • This is exactly what I was looking for. Thank you a lot @pkpnd
    – xFunkyTImes
    Nov 13 '18 at 8:30















2














Your solution is correct. Here's a different approach with the same result:



t(1) = 0 (given)
t(2) = t(1) + 1 = 1
t(3) = t(2) + 2 = 1 + 2 = 3
t(4) = t(3) + 3 = 1 + 2 + 3 = 6
...
t(n) = 1 + 2 + ... + (n-1) = n * (n - 1) / 2 = Theta(n^2).


The teacher's solution is wrong after the second = sign. Here's what the teacher wrote:



t(n-1) + n - 1 = t(n-2) + n - 1 - 2


But actually the following is correct:



t(n-1) + n - 1 = ( t(n-2) + n - 2 ) + n - 1


which is actually exactly what you got. It appears that the teacher dropped an n term.



In fact, the teacher's solution ends with a dominant term of -n^2 which is clearly wrong, as t(n) >= 0 for all n >= 0.






share|improve this answer




















  • This is exactly what I was looking for. Thank you a lot @pkpnd
    – xFunkyTImes
    Nov 13 '18 at 8:30













2












2








2






Your solution is correct. Here's a different approach with the same result:



t(1) = 0 (given)
t(2) = t(1) + 1 = 1
t(3) = t(2) + 2 = 1 + 2 = 3
t(4) = t(3) + 3 = 1 + 2 + 3 = 6
...
t(n) = 1 + 2 + ... + (n-1) = n * (n - 1) / 2 = Theta(n^2).


The teacher's solution is wrong after the second = sign. Here's what the teacher wrote:



t(n-1) + n - 1 = t(n-2) + n - 1 - 2


But actually the following is correct:



t(n-1) + n - 1 = ( t(n-2) + n - 2 ) + n - 1


which is actually exactly what you got. It appears that the teacher dropped an n term.



In fact, the teacher's solution ends with a dominant term of -n^2 which is clearly wrong, as t(n) >= 0 for all n >= 0.






share|improve this answer












Your solution is correct. Here's a different approach with the same result:



t(1) = 0 (given)
t(2) = t(1) + 1 = 1
t(3) = t(2) + 2 = 1 + 2 = 3
t(4) = t(3) + 3 = 1 + 2 + 3 = 6
...
t(n) = 1 + 2 + ... + (n-1) = n * (n - 1) / 2 = Theta(n^2).


The teacher's solution is wrong after the second = sign. Here's what the teacher wrote:



t(n-1) + n - 1 = t(n-2) + n - 1 - 2


But actually the following is correct:



t(n-1) + n - 1 = ( t(n-2) + n - 2 ) + n - 1


which is actually exactly what you got. It appears that the teacher dropped an n term.



In fact, the teacher's solution ends with a dominant term of -n^2 which is clearly wrong, as t(n) >= 0 for all n >= 0.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 13 '18 at 0:14









pkpnd

4,5711140




4,5711140











  • This is exactly what I was looking for. Thank you a lot @pkpnd
    – xFunkyTImes
    Nov 13 '18 at 8:30
















  • This is exactly what I was looking for. Thank you a lot @pkpnd
    – xFunkyTImes
    Nov 13 '18 at 8:30















This is exactly what I was looking for. Thank you a lot @pkpnd
– xFunkyTImes
Nov 13 '18 at 8:30




This is exactly what I was looking for. Thank you a lot @pkpnd
– xFunkyTImes
Nov 13 '18 at 8:30

















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • 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.

To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • 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.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53270157%2fsolving-a-recurrence-relation-tn-tn-1-n-1%23new-answer', 'question_page');

);

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







這個網誌中的熱門文章

How to read a connectionString WITH PROVIDER in .NET Core?

In R, how to develop a multiplot heatmap.2 figure showing key labels successfully

Museum of Modern and Contemporary Art of Trento and Rovereto