780 likes | 819 Vues
Advanced Counting Techniques. CSC-2259 Discrete Structures. Recurrence Relations. Sequence. Recurrence relation:. For any. Example:. Recurrence relation. Solutions to recurrence relation:. Example:. $10,000 bank deposit. %11 interest. :amount after years. Example:.
E N D
Advanced Counting Techniques CSC-2259 Discrete Structures Konstantin Busch - LSU
Recurrence Relations Sequence Recurrence relation: For any Konstantin Busch - LSU
Example: Recurrence relation Solutions to recurrence relation: Konstantin Busch - LSU
Example: $10,000 bank deposit %11 interest :amount after years Konstantin Busch - LSU
Example: Fibonacci sequence Konstantin Busch - LSU
Example: Towers of Hanoi bar1 bar2 bar3 discs Goal: move all discs to bar3 Rule: not allowed to put larger discs on top of smaller discs Konstantin Busch - LSU
bar1 bar2 bar3 Step 1: move recursively discs to bar2 Konstantin Busch - LSU
bar1 bar2 bar3 Step 2: move largest disc to bar3 Konstantin Busch - LSU
bar1 bar2 bar3 Step 3: move recursively discs to bar3 Konstantin Busch - LSU
:total disc moves 2 recursive calls with discs (steps 1&3) movement of largest disc (step 2) one move for one disc Konstantin Busch - LSU
Solving Linear Recurrence Relations Linear homogeneous recurrence relation of degree : Constant coefficients: Konstantin Busch - LSU
A sequence (solution) satisfying the relation is uniquely determined by the initial values: (these are different constants than the coefficients) Konstantin Busch - LSU
Solution to recurrence relation: if an only if divide both sides with characteristic equation Konstantin Busch - LSU
characteristic equation: factorize with roots characteristic roots: Multiple possible solutions: Konstantin Busch - LSU
The solutions may not satisfy the initial conditions Konstantin Busch - LSU
Theorem: Recurrence relation of degree 2 has unique solution where are solutions to the characteristic equation, and are constants that depend on initial conditions Konstantin Busch - LSU
Proof: Characteristic Equation Roots: Konstantin Busch - LSU
First compute from initial conditions Konstantin Busch - LSU
Prove by induction that Basis cases: true for the specific choices of Konstantin Busch - LSU
Inductive hypothesis: assume that for all Inductive step: prove that for Konstantin Busch - LSU
By (strong) inductive hypothesis: Konstantin Busch - LSU
By recurrence relation definition Inductive hypothesis characteristic equations End of Proof Konstantin Busch - LSU
Example: Fibonacci sequence Has solution: Characteristic roots: Konstantin Busch - LSU
Degree recurrence relation: has unique solution where are solutions to the characteristic equation, and are constants that depend on initial conditions Konstantin Busch - LSU
Example: Solution: Characteristic equation: Roots: Konstantin Busch - LSU
Final solution: Konstantin Busch - LSU
Recurrence Relations for Divide and Conquer Algorithms Typical divide and conquer algorithm: • Input of size • Divide into sub-problems • each of size • Combine sub-problems with cost Konstantin Busch - LSU
Divide an conquer recurrence relation: Cost of subproblem of size Konstantin Busch - LSU
Examples: Binary search: Merge Sort: Fast Matrix Multiplication (Stassen’s Alg.): Konstantin Busch - LSU
Theorem: if then Konstantin Busch - LSU
Proof: Konstantin Busch - LSU
End of Proof Konstantin Busch - LSU
Theorem: if then Konstantin Busch - LSU
Proof: From previous theorem Konstantin Busch - LSU
Case: Konstantin Busch - LSU
Case: End of Proof Konstantin Busch - LSU
Example: Binary search: Konstantin Busch - LSU
Master Theorem: if then Konstantin Busch - LSU
Example: Merge Sort: Konstantin Busch - LSU
Example: Fast Matrix Multiplication (Stassen’s Alg.): Konstantin Busch - LSU
Generating Functions Find number of solutions for: Answer: Konstantin Busch - LSU
Alternative solution choices for choices for choices for Konstantin Busch - LSU
Alternative solution is the total number of solutions to equation Konstantin Busch - LSU
Another problem: Find total number of solutions which satisfy: Konstantin Busch - LSU
Alternative solution choices for choices for choices for Konstantin Busch - LSU