Presentation is loading. Please wait.

Presentation is loading. Please wait.

Advanced Counting Techniques CSC-2259 Discrete Structures Konstantin Busch - LSU1.

Similar presentations


Presentation on theme: "Advanced Counting Techniques CSC-2259 Discrete Structures Konstantin Busch - LSU1."— Presentation transcript:

1 Advanced Counting Techniques CSC-2259 Discrete Structures Konstantin Busch - LSU1

2 Recurrence Relations Konstantin Busch - LSU2 Sequence Recurrence relation: For any

3 Konstantin Busch - LSU3 Example: Solutions to recurrence relation: Recurrence relation

4 Konstantin Busch - LSU4 $10,000 bank deposit %11 interest :amount after years Example:

5 Konstantin Busch - LSU5 Fibonacci sequence Example:

6 Konstantin Busch - LSU6 Towers of HanoiExample: bar1bar2bar3 Goal: move all discs to bar3 Rule: not allowed to put larger discs on top of smaller discs discs

7 Konstantin Busch - LSU7 bar1bar2bar3 move recursively discs to bar2Step 1:

8 Konstantin Busch - LSU8 bar1bar2bar3 move largest disc to bar3Step 2:

9 Konstantin Busch - LSU9 bar1bar2bar3 move recursively discs to bar3Step 3:

10 Konstantin Busch - LSU10 :total disc moves 2 recursive calls with discs (steps 1&3) movement of largest disc (step 2) one move for one disc

11 Konstantin Busch - LSU11

12 Solving Linear Recurrence Relations Konstantin Busch - LSU12 Linear homogeneous recurrence relation of degree : Constant coefficients:

13 Konstantin Busch - LSU13 A sequence (solution) satisfying the relation is uniquely determined by the initial values: (these are different constants than the coefficients)

14 Konstantin Busch - LSU14 if an only if Solution to recurrence relation: divide both sides with characteristic equation

15 Konstantin Busch - LSU15 characteristic equation: factorize with roots characteristic roots: Multiple possible solutions:

16 Konstantin Busch - LSU16 The solutions may not satisfy the initial conditions

17 Konstantin Busch - LSU17 Theorem:Recurrence relation of degree 2 has unique solution where are solutions to the characteristic equation, and are constants that depend on initial conditions

18 Konstantin Busch - LSU18 Characteristic Equation Roots: Proof:

19 Konstantin Busch - LSU19 First compute from initial conditions

20 Konstantin Busch - LSU20

21 Konstantin Busch - LSU21 Prove by induction that Basis cases: true for the specific choices of

22 Konstantin Busch - LSU22 Inductive hypothesis: for all Inductive step: for prove that assume that

23 Konstantin Busch - LSU23 By (strong) inductive hypothesis:

24 Konstantin Busch - LSU24 By recurrence relation definition Inductive hypothesis End of Proof characteristic equations

25 Konstantin Busch - LSU25 Fibonacci sequence Example: Has solution: Characteristic roots:

26 Konstantin Busch - LSU26

27 Konstantin Busch - LSU27

28 Konstantin Busch - LSU28 Degree recurrence relation: has unique solution where are solutions to the characteristic equation, and are constants that depend on initial conditions

29 Konstantin Busch - LSU29 Example: Solution: Characteristic equation: Roots:

30 Konstantin Busch - LSU30 Final solution:

31 Recurrence Relations for Divide and Conquer Algorithms Konstantin Busch - LSU31 Typical divide and conquer algorithm: Input of size Divide into sub-problems each of size Combine sub-problems with cost

32 Konstantin Busch - LSU32 Divide an conquer recurrence relation: Cost of subproblem of size

33 Konstantin Busch - LSU33 Examples: Binary search: Merge Sort: Fast Matrix Multiplication (Stassen’s Alg.):

34 Konstantin Busch - LSU34 Theorem: if then

35 Konstantin Busch - LSU35 Proof:

36 Konstantin Busch - LSU36

37 Konstantin Busch - LSU37 End of Proof

38 Konstantin Busch - LSU38 Theorem: if then

39 Konstantin Busch - LSU39 Proof: From previous theorem

40 Konstantin Busch - LSU40 Case:

41 Konstantin Busch - LSU41 Case: End of Proof

42 Konstantin Busch - LSU42 Example: Binary search:

43 Konstantin Busch - LSU43 Master Theorem: if then

44 Konstantin Busch - LSU44 Example: Merge Sort:

45 Konstantin Busch - LSU45 Example: Fast Matrix Multiplication (Stassen’s Alg.):

46 Generating Functions Konstantin Busch - LSU46 Find number of solutions for: Answer:

47 Konstantin Busch - LSU47 Alternative solution choices for

48 Konstantin Busch - LSU48 Alternative solution is the total number of solutions to equation

49 Konstantin Busch - LSU49 Another problem: Find total number of solutions which satisfy:

50 Konstantin Busch - LSU50 Alternative solution choices for

51 Konstantin Busch - LSU51 Alternative solution is the total number of solutions to equation

52 Konstantin Busch - LSU52 Generating function: generating function for sequence

53 Konstantin Busch - LSU53 Solve recurrence relation Generating functions can also be used to solve recurrence relations Example:

54 Konstantin Busch - LSU54 Let be the generating function for sequence

55 Konstantin Busch - LSU55

56 Konstantin Busch - LSU56

57 Konstantin Busch - LSU57

58 Konstantin Busch - LSU58

59 Konstantin Busch - LSU59 Solution to recurrence relation

60 Inclusion-Exclusion Konstantin Busch - LSU60

61 Konstantin Busch - LSU61

62 Konstantin Busch - LSU62 Principle of Inclusion-Exclusion:

63 Konstantin Busch - LSU63 Proof: We want to prove that: an arbitrary element is counted exactly one time in the expression of the theorem

64 Konstantin Busch - LSU64 Suppose is a member of exactly sets: Then is counted in the terms:

65 is counted times Konstantin Busch - LSU65 In sum: (since belongs exactly to sets)

66 is counted times Konstantin Busch - LSU66 In sum: (since belongs exactly to sets)

67 is counted times Konstantin Busch - LSU67 In sum: (since belongs exactly to sets)

68 is counted times Konstantin Busch - LSU68 In sum: (since belongs exactly to sets)

69 Konstantin Busch - LSU69 Thus, in the expression of the theorem is counted so many times:

70 Konstantin Busch - LSU70 End of Proof From binomial expansion we have that: Thus, is counted exactly one time

71 Konstantin Busch - LSU71 Example:Find the number of primes between 1…100 If a number is composite and between 1…100 then it must be divided by a prime which is at most : 2, 3, 5, 7

72 Konstantin Busch - LSU72 :the set of primes between 1…100 :composites between 1…100 divided by 2 :composites between 1…100 divided by 3 :the set of composites between 1…100 :composites between 1…100 divided by 5 :composites between 1…100 divided by 7

73 Konstantin Busch - LSU73 From the principle of inclusion-exclusion:

74 Konstantin Busch - LSU74

75 Konstantin Busch - LSU75 Number of primes between 1…100:

76 Konstantin Busch - LSU76 Dearrangements: given some ordered list, permutations that have no item in original position Example:1 2 3 4 5 5 1 2 3 4 Dearrangements: 3 5 4 1 2 2 1 4 5 3

77 Konstantin Busch - LSU77 Theorem: Given a list with elements, the number of dearrangements are

78 Konstantin Busch - LSU78 :set of all permutations :permutations which fix position


Download ppt "Advanced Counting Techniques CSC-2259 Discrete Structures Konstantin Busch - LSU1."

Similar presentations


Ads by Google