chapter 7 - RecurrenceRelations...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
Recurrence Relations  1/25 Recurrence Relations  An equation that allow us to compute the n th  term  of a sequence from preceding terms.  Example1: The selection sort In the selection sort algorithm the total number of  comparisons is given by   0 if  n = 1 C n               C n-1  + n-1 for n > 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Recurrence Relations  2/25 Example2: The subset recurrence The subset recurrence: let S n  be the number of subsets of N =  {1, 2, 3,…. ., n-1, n}, then  S n   can be computed from S n-1  (which is the number of subsets  of  {1, 2, …. .,n-1}  as follows: Let N’ = {1, 2, …. .,n-1}, S n-1  is the number of  subsets of N’.  Now subsets of N are either contain N or does not.  The subsets of N that do not contain n are the subsets of N’.  Their number is S n-1 . The subsets of N that contain n are the subsets of N’ with n  added to each subset. Their number is S n-1 .
Background image of page 2
Recurrence Relations  3/25 Example2: The subset recurrence                       2 * S n-1  for n > 1 Thus S n  =                       S 0  = 1 for n= 0 where S 0  is the number of subsets of the empty set. Can we find out the first 5 terms of S n ?    
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Recurrence Relations  4/25 Example3: The Bijection Recurrence What is the number of one-to-one onto functions  from a set A = {1, 2,…., n} to a set T with n  elements? Does it depend on n? if so? Let it be b n . We would like to find it.
Background image of page 4
Recurrence Relations  5/25 Example3: The Bijection Recurrence b n  can defined recursively since for a function f  f(n) has n choices let it be t &  the numbers {1, 2,…., n- 1} have to be mapped to the remaining n-1 elements of  T.  The number of bijections is b n-1 Thus by the product principle there are n*b n-1  choices.  That is b n =n*b n-1 Also notice that b 1  = 1      
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Recurrence Relations  6/25 The order of the recurrence relation In the previous examples the n th  term is computed  from the n th-1  term without using other previous  terms such as the n th-2  term. Such a recurrence relations is called a first order  recurrence relation. A recurrence relation is said to be of the r th  order if  computing the n th  term requires computing the  preceding r terms.  What is the order of the Fibonacci number?  f(n) = f(n-1) + f(n-2) and both f(0) & f(1) = 1   
Background image of page 6
Recurrence Relations  7/25 Linear recurrence relations A first order recurrence relation is called linear  recurrence relations if the n th  term can be  computed as a = b(n) * a
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 27

chapter 7 - RecurrenceRelations...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online