0 votes 0 votes cant we write the recurrance relation for bar() as T(n) = 5T(n-1) + c, like cant we take both the recurrance call as combined as both have same parameter? and if not, then how to solve such? Algorithms time-complexity algorithms made-easy-test-series asymptotic-notation + – Markzuck asked Dec 29, 2018 • edited Mar 5, 2019 by Rishi yadav Markzuck 791 views answer comment Share Follow See all 7 Comments See all 7 7 Comments reply Utkarsh Joshi commented Dec 29, 2018 reply Follow Share can't see "foo" 0 votes 0 votes Markzuck commented Dec 29, 2018 reply Follow Share Sorry, was asking for bar(), edited 0 votes 0 votes Utkarsh Joshi commented Dec 29, 2018 reply Follow Share you can write it as, bar(n)= bar(n-1) + bar(n-1) = 2bar(n-1) 0 votes 0 votes gauravkc commented Dec 29, 2018 reply Follow Share @Markzuck It is 3 multiplied by what bar(n-1) returns and not 3 bar(n-1) function calls. 0 votes 0 votes Markzuck commented Dec 29, 2018 reply Follow Share Ohh got it So while calling we need to write separately? Like 5*tn-1 means 5*return value But in complexity eqn we just write number of times called which is 2? Not 5tn-1 right? 0 votes 0 votes gauravkc commented Dec 29, 2018 reply Follow Share Yes.What matters is how many times the function is getting called. It is getting called twice in your example. 1 votes 1 votes luc_Bloodstone commented Nov 25, 2019 reply Follow Share I don't understand how it gets T(n) = O(2^n). I try solving it and I am getting this equation: T(n) = 2^(n-1) * 3^(n) + ( 2^(n-2) -1 ) so by this leading term will be O(2^n * 3^n) Please if someone know where I did this wrong. 0 votes 0 votes Please log in or register to add a comment.
0 votes 0 votes 2T(n-1)+1 will give us O(2^n) UrbanCsGuy answered Feb 15, 2021 UrbanCsGuy comment Share Follow See all 0 reply Please log in or register to add a comment.