50 likes | 226 Views
Recursion and Recurrence Relations. An Introduction. Recursion. A technique of defining a function, a set or an algorithm in terms of itself is a “recursion”. For Example: Factorial !n=n X !(n-1), and !0=! 1=1 Fibonacci sequence f 0 =1, f 1 =1 and f k =f k-2 +f k-1 for k≥2 .
E N D
Recursion and Recurrence Relations An Introduction
Recursion • A technique of defining a function, a set or an algorithm in terms of itself is a “recursion”. • For Example: • Factorial !n=n X !(n-1), and !0=!1=1 • Fibonacci sequence f0 =1, f1 =1 and fk =fk-2 +fk-1 for k≥2
Solution of a problem with recursion and Iteration • Lets solve this problem with to methods • Recursion • Iteration Telescoping form of a polynomial expression Eg. X5 + 3x4 – 15x2 +x -10 Its telescoping form is (((x((x)+3)))x-15)x+1)x-10
Types of Recurrence Relation • Linear Recurrence relation with constant coefficients. c0ar + c1 ar-1 + c2 ar-2 + ……..+ ckar-k =f(r) • Homogeneous recurrence Relation s(k)+c1 s(k-1) +c2 s(k-2)+…….+ cn s(k-n)=f(k) and f(n)=0 • Non-Homogeneous recurrence Relation • s(k)+c1 s(k-1) +c2 s(k-2)+…….+ cn s(k-n)=f(k) and f(n)=non-zero.