I have one recurrence relation not able to solve
Recurrence relation
hello @Vikaspal
t(n)=t(n-1) + log(n)
t(n-1)=t(n-2)+log(n-1)
t(n-2)=t(n-2)+log(n-2)
t(n-3)=t(n-4)+log(n-3)
…
…
…
…
t(1)=1
add all equations
t(n)=log(1)+log(2)+log(3)+log(4)+log(5)…log(n-2)+log(n-1)+log(n)
using log property log(a)+log(b)=log(ab)
t(n)=log(12345…n-1n)
1234…n-1*n (it is n! right)
t(n)=log(n!)
t(n)=nlog(n)
nlog(n) is correct solution
you can think it like this
t(n) =log(n) +log(n-1) +log(n-2)+log(n-3)…
since n is really big (we always assume while deriving time complexity)
n = n-1 =n-2=n-3=n-4 =n-5=n-6…(all can be treated n because subtracting 1 ,2 ,3… from a very big numberr will have very negligible effect).
we can write n-1 as n, n-2 as n, n-k as n.
so we can write it as
t(n)=log(n)+log(n)+log(n) …n times because n to 1 it takes n steps
t(n)=n*log(n)
i think it should be clear to u now
@aman212yadav great I am doing wrong when we have some like additiion of log so i must have to log property instead of calculating the individual log term right ??
yeah ,there r few 3…4 log property that u can revise for solving these type of problem.
@aman212yadav and also which gp formula i used somewhere i see that for calculating the nth term a(1-r^n)/1-r or a(r^n - 1)/r-1 is used ?
both are same na.
taking -1 common form numerator and denominator.
one expression will convert to other.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.