Recurrence RelationA recurrence is an equation or inequality that describes a function in terms of its values on smaller inputs. To solve a Recurrence Relation means to obtain a function defined on the natural numbers that satisfy the recurrence. For Example, the Worst Case Running Time T(n) of the MERGE SORT Procedures is described by the recurrence. T (n) = θ (1) if n=1 2T + θ (n) if n>1 There are four methods for solving Recurrence: 1. Substitution Method:The Substitution Method Consists of two main steps:
For Example1 Solve the equation by Substitution Method. T (n) = T + n We have to show that it is asymptotically bound by O (log n). Solution: For T (n) = O (log n) We have to show that for some constant c Put this in given Recurrence Equation. T (n) ≤c log+ 1 ≤c log+ 1 = c lognclog_{2} 2+1 ≤c logn for c≥1 Thus T (n) =O logn. Example2 Consider the Recurrence T (n) = 2T+ n n>1 Find an Asymptotic bound on T. Solution: We guess the solution is O (n (logn)).Thus for constant 'c'. T (n) ≤c n logn Put this in given Recurrence Equation. Now, T (n) ≤2clog +n ≤cnlogncnlog2+n =cn lognn (clog21) ≤cn logn for (c≥1) Thus T (n) = O (n logn). 2. Iteration MethodsIt means to expand the recurrence and express it as a summation of terms of n and initial condition. Example1: Consider the Recurrence Solution: T (n) = 2T (n1) = 2[2T (n2)] = 2^{2}T (n2) = 4[2T (n3)] = 2^{3}T (n3) = 8[2T (n4)] = 2^{4}T (n4) (Eq.1) Repeat the procedure for i times T (n) = 2^{i} T (ni) Put ni=1 or i= n1 in (Eq.1) T (n) = 2^{n1} T (1) = 2^{n1} .1 {T (1) =1 .....given} = 2^{n1} Example2: Consider the Recurrence Solution: T (n) = T (n1) +1 = (T (n2) +1) +1 = (T (n3) +1) +1+1 = T (n4) +4 = T (n5) +1+4 = T (n5) +5= T (nk) + k Where k = n1 T (nk) = T (1) = θ (1) T (n) = θ (1) + (n1) = 1+n1=n= θ (n).
Next TopicRecursion Tree Method
