advanced counting techniques
play

Advanced Counting Techniques CS1200, CSE IIT Madras Meghana Nasre - PowerPoint PPT Presentation

Advanced Counting Techniques CS1200, CSE IIT Madras Meghana Nasre April 16, 2020 CS1200, CSE IIT Madras Meghana Nasre Advanced Counting Techniques Advanced Counting Techniques Principle of Inclusion-Exclusion Recurrences and its


  1. Advanced Counting Techniques CS1200, CSE IIT Madras Meghana Nasre April 16, 2020 CS1200, CSE IIT Madras Meghana Nasre Advanced Counting Techniques

  2. Advanced Counting Techniques • Principle of Inclusion-Exclusion � • Recurrences and its applications � • Solving Recurrences CS1200, CSE IIT Madras Meghana Nasre Advanced Counting Techniques

  3. Recap: Solving recurrences We have seen • Method of Repeated Substitution. • Linear Homogeneous recurrence relations with constant coefficients. • Use of characteristic equation to solve these recurrences. CS1200, CSE IIT Madras Meghana Nasre Advanced Counting Techniques

  4. Recap: Solving recurrences We have seen • Method of Repeated Substitution. • Linear Homogeneous recurrence relations with constant coefficients. • Use of characteristic equation to solve these recurrences. Today: • Non-homogeneous case. • Comparing functions (a short detour). CS1200, CSE IIT Madras Meghana Nasre Advanced Counting Techniques

  5. Example 1 a n = 3 · n · 2 n − a n − 1 • This is a non-homogeneous linear recurrence with constant coefficients. The presence of the term F ( n ) = 3 · n · 2 n makes it non-homogeneous. CS1200, CSE IIT Madras Meghana Nasre Advanced Counting Techniques

  6. Example 1 a n = 3 · n · 2 n − a n − 1 • This is a non-homogeneous linear recurrence with constant coefficients. The presence of the term F ( n ) = 3 · n · 2 n makes it non-homogeneous. • The recurrence a n = − a n − 1 is the “associated homogeneous recurrence” . We know the general form for the solution : CS1200, CSE IIT Madras Meghana Nasre Advanced Counting Techniques

  7. Example 1 a n = 3 · n · 2 n − a n − 1 • This is a non-homogeneous linear recurrence with constant coefficients. The presence of the term F ( n ) = 3 · n · 2 n makes it non-homogeneous. • The recurrence a n = − a n − 1 is the “associated homogeneous recurrence” . We know the general form for the solution : call this solution { a ( h ) n } . For the example it is α 1 · ( − 1) n . CS1200, CSE IIT Madras Meghana Nasre Advanced Counting Techniques

  8. Example 1 a n = 3 · n · 2 n − a n − 1 • This is a non-homogeneous linear recurrence with constant coefficients. The presence of the term F ( n ) = 3 · n · 2 n makes it non-homogeneous. • The recurrence a n = − a n − 1 is the “associated homogeneous recurrence” . We know the general form for the solution : call this solution { a ( h ) n } . For the example it is α 1 · ( − 1) n . • Suppose there is a solution to the non-homogeneous recurrence that we somehow guess!, lets call it { a ( p ) n } . CS1200, CSE IIT Madras Meghana Nasre Advanced Counting Techniques

  9. Example 1 a n = 3 · n · 2 n − a n − 1 • This is a non-homogeneous linear recurrence with constant coefficients. The presence of the term F ( n ) = 3 · n · 2 n makes it non-homogeneous. • The recurrence a n = − a n − 1 is the “associated homogeneous recurrence” . We know the general form for the solution : call this solution { a ( h ) n } . For the example it is α 1 · ( − 1) n . • Suppose there is a solution to the non-homogeneous recurrence that we somehow guess!, lets call it { a ( p ) n } . Note that this may still not satisfy base cases. CS1200, CSE IIT Madras Meghana Nasre Advanced Counting Techniques

  10. Example 1 a n = 3 · n · 2 n − a n − 1 • This is a non-homogeneous linear recurrence with constant coefficients. The presence of the term F ( n ) = 3 · n · 2 n makes it non-homogeneous. • The recurrence a n = − a n − 1 is the “associated homogeneous recurrence” . We know the general form for the solution : call this solution { a ( h ) n } . For the example it is α 1 · ( − 1) n . • Suppose there is a solution to the non-homogeneous recurrence that we somehow guess!, lets call it { a ( p ) n } . Note that this may still not satisfy base cases. 3 ) · 2 n satisfies the given recurrence. In the example, the formula (2 n + 2 CS1200, CSE IIT Madras Meghana Nasre Advanced Counting Techniques

  11. Example 1 a n = 3 · n · 2 n − a n − 1 • This is a non-homogeneous linear recurrence with constant coefficients. The presence of the term F ( n ) = 3 · n · 2 n makes it non-homogeneous. • The recurrence a n = − a n − 1 is the “associated homogeneous recurrence” . We know the general form for the solution : call this solution { a ( h ) n } . For the example it is α 1 · ( − 1) n . • Suppose there is a solution to the non-homogeneous recurrence that we somehow guess!, lets call it { a ( p ) n } . Note that this may still not satisfy base cases. 3 ) · 2 n satisfies the given recurrence. In the example, the formula (2 n + 2 Then the solution to the given recurrence is of the form { a ( p ) n } + { a ( h ) { a n } = n } CS1200, CSE IIT Madras Meghana Nasre Advanced Counting Techniques

  12. Example 1 a n = 3 · n · 2 n − a n − 1 • This is a non-homogeneous linear recurrence with constant coefficients. The presence of the term F ( n ) = 3 · n · 2 n makes it non-homogeneous. • The recurrence a n = − a n − 1 is the “associated homogeneous recurrence” . We know the general form for the solution : call this solution { a ( h ) n } . For the example it is α 1 · ( − 1) n . • Suppose there is a solution to the non-homogeneous recurrence that we somehow guess!, lets call it { a ( p ) n } . Note that this may still not satisfy base cases. 3 ) · 2 n satisfies the given recurrence. In the example, the formula (2 n + 2 Then the solution to the given recurrence is of the form { a ( p ) n } + { a ( h ) { a n } = n } � 2 n + 2 � · 2 n + α 1 ( − 1) n = 3 CS1200, CSE IIT Madras Meghana Nasre Advanced Counting Techniques

  13. Example 1 a n = 3 · n · 2 n − a n − 1 • This is a non-homogeneous linear recurrence with constant coefficients. The presence of the term F ( n ) = 3 · n · 2 n makes it non-homogeneous. • The recurrence a n = − a n − 1 is the “associated homogeneous recurrence” . We know the general form for the solution : call this solution { a ( h ) n } . For the example it is α 1 · ( − 1) n . • Suppose there is a solution to the non-homogeneous recurrence that we somehow guess!, lets call it { a ( p ) n } . Note that this may still not satisfy base cases. 3 ) · 2 n satisfies the given recurrence. In the example, the formula (2 n + 2 Then the solution to the given recurrence is of the form { a ( p ) n } + { a ( h ) { a n } = n } � 2 n + 2 � · 2 n + α 1 ( − 1) n = 3 If base case is a 1 = 1 we get α 1 = 13 3 . Check out the formula works! CS1200, CSE IIT Madras Meghana Nasre Advanced Counting Techniques

  14. Example 1 continued a n = 3 · n · 2 n − a n − 1 • This is a non-homogeneous linear recurrence with constant coefficients. The presence of the term F ( n ) = 3 · n · 2 n makes it non-homogeneous. • The recurrence a n = − a n − 1 is the “associated homogeneous recurrence” . We know the general form for the solution : call this solution { a ( h ) n } . For the example it is α 1 · ( − 1) n . • Suppose there is a solution to the non-homogeneous recurrence that we somehow guess!, lets call it { a ( p ) n } . Note that this may still not satisfy base cases. 3 ) · 2 n satisfies the given recurrence. In the example, the formula (2 n + 2 CS1200, CSE IIT Madras Meghana Nasre Advanced Counting Techniques

  15. Example 1 continued a n = 3 · n · 2 n − a n − 1 • This is a non-homogeneous linear recurrence with constant coefficients. The presence of the term F ( n ) = 3 · n · 2 n makes it non-homogeneous. • The recurrence a n = − a n − 1 is the “associated homogeneous recurrence” . We know the general form for the solution : call this solution { a ( h ) n } . For the example it is α 1 · ( − 1) n . • Suppose there is a solution to the non-homogeneous recurrence that we somehow guess!, lets call it { a ( p ) n } . Note that this may still not satisfy base cases. 3 ) · 2 n satisfies the given recurrence. In the example, the formula (2 n + 2 Some unanswered questions: • Why can we add the two solutions? That is, why is { a n } = { a ( p ) n } + { a ( h ) n } ? • How did we guess (2 n + 2 3 ) · 2 n ? • Does it depend on the function F ( n )? CS1200, CSE IIT Madras Meghana Nasre Advanced Counting Techniques

  16. Non-Homogeneous Case Why can we add the two solutions? That is, why is { a n } = { a ( p ) n } + { a ( h ) n } ? a n = c 1 a n − 1 + c 2 a n − 2 + . . . + c k a n − k + F ( n ) CS1200, CSE IIT Madras Meghana Nasre Advanced Counting Techniques

  17. Non-Homogeneous Case Why can we add the two solutions? That is, why is { a n } = { a ( p ) n } + { a ( h ) n } ? a n = c 1 a n − 1 + c 2 a n − 2 + . . . + c k a n − k + F ( n ) • Let { a ( p ) n } be some (guessed!) solution to the recurrence (not necessarily satisfying base cases). CS1200, CSE IIT Madras Meghana Nasre Advanced Counting Techniques

  18. Non-Homogeneous Case Why can we add the two solutions? That is, why is { a n } = { a ( p ) n } + { a ( h ) n } ? a n = c 1 a n − 1 + c 2 a n − 2 + . . . + c k a n − k + F ( n ) • Let { a ( p ) n } be some (guessed!) solution to the recurrence (not necessarily satisfying base cases). • Let { b n } be another solution to the recurrence. CS1200, CSE IIT Madras Meghana Nasre Advanced Counting Techniques

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend