Recurrence relation: T(n) = T(n/2) + n -
hi there trying solve following recurrence relation telescoping stuck on last step.
t(n) = t(n/2) + n t(1)=0 t(n/2) = t(n/4) + n/2 t(n/4) = t(n/8) + n/4 ... t(2) = t(1) + 2 t(n)= t(1) + n + n/2 + n/4 i think answer nlogn don't know how interpret above nlogn. can see doing logn steps n come from?
you have done absolutely correctly, not able find sum. got: n + n/2 + n/4 + ..., equal n * (1 + 1/2 + 1/4 + ...).
you got sum of geometric series, equal 2. therefore sum 2n. complexity o(n).
p.s. not called telescoping. telescoping in math when subsequent terms cancel each other.
Comments
Post a Comment