Counting Strategies Mohammad Reza Karimi Department of Computer Engineering Sharif University of Technology m.r.karimi.j@gmail.com March 15, 2014 . .. .. . . .. .. .. . . .. .. .. . . .. .. .. . . .. . . .. .. . Addition, Multiplication . Example . Determine the number of squares with all their vertices belonging to the . 10 × 10 array of lattice points. . . . . . . . . . . . . . . . .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. M. R. Karimi (SUT) Counting Strategies March 2014 . .. . . . . .. .. .. 2 / 11 Addition, Multiplication . Example . Determine the number of squares with all their vertices belonging to the . 10 × 10 array of lattice points. Solution idea: each “rotated square” can be inscribed in a horizontal square. . . . . . . . . . . . . . . . .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. M. R. Karimi (SUT) Counting Strategies March 2014 . .. . . . . .. .. .. 2 / 11 Addition, Multiplication . Example . Determine the number of squares with all their vertices belonging to the . 10 × 10 array of lattice points. Solution idea: each “rotated square” can be inscribed in a horizontal square. Final answer: 9 ∑ (10 − k)2 · k k=1 . . . . . . . . . . . . . . . .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. M. R. Karimi (SUT) Counting Strategies March 2014 . .. . . . . .. .. .. 2 / 11 Addition, Multiplication . Example . Determine the number of squares with all their vertices belonging to the . 10 × 10 array of lattice points. Solution idea: each “rotated square” can be inscribed in a horizontal square. Final answer: 9 ∑ (10 − k)2 · k k=1 . Example . There are n sticks of length 1, 2, . . . , n. How many incongruent triangles can be formed by using three of the given sticks? . . . . . . . . . . . . . . . . .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. M. R. Karimi (SUT) Counting Strategies March 2014 . .. . . . . .. .. .. 2 / 11 Addition, Multiplication . Example . Determine the number of squares with all their vertices belonging to the . 10 × 10 array of lattice points. Solution idea: each “rotated square” can be inscribed in a horizontal square. Final answer: 9 ∑ (10 − k)2 · k k=1 . Example . There are n sticks of length 1, 2, . . . , n. How many incongruent triangles can be formed by using three of the given sticks? . Solution idea: Triangle inequality. . . . . . . . . . . . . . . . .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. M. R. Karimi (SUT) Counting Strategies March 2014 . .. . . . . .. .. .. 2 / 11 Grouping . Example . Determine the number of seven-letter codes such that (i) no letters are repeated in the code; and (ii) . letters a and b are not next to each other. . . . . . . . . . . . . . . . .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. M. R. Karimi (SUT) Counting Strategies March 2014 . .. . . . . .. .. .. 3 / 11 Grouping . Example . Determine the number of seven-letter codes such that (i) no letters are repeated in the code; and (ii) . letters a and b are not next to each other. Solution idea: Group a and b into a pack. Find complement answer. . . . . . . . . . . . . . . . .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. M. R. Karimi (SUT) Counting Strategies March 2014 . .. . . . . .. .. .. 3 / 11 Combinations . Example . Twenty-five of King Arthur’s knights are seated at their customary round table. Three of them are chosen- all choices of three being equally likely-and are sent off to slay a troublesome dragon. What is the probability that at least two of the three were seated next to each other? . . . . . . . . . . . . . . . . .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. M. R. Karimi (SUT) Counting Strategies March 2014 . .. . . . . .. .. .. 4 / 11 Combinations . Example . Twenty-five of King Arthur’s knights are seated at their customary round table. Three of them are chosen- all choices of three being equally likely-and are sent off to slay a troublesome dragon. What is the probability that at least two of the three were seated next to each other? . Answer 1: n + n(n − 4) = n(n − 3) . . . . . . . . . . . . . . . .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. M. R. Karimi (SUT) Counting Strategies March 2014 . .. . . . . .. .. .. 4 / 11 Combinations . Example . Twenty-five of King Arthur’s knights are seated at their customary round table. Three of them are chosen- all choices of three being equally likely-and are sent off to slay a troublesome dragon. What is the probability that at least two of the three were seated next to each other? . Answer 1: n + n(n − 4) = n(n − 3) Answer 2: n(n − 2) − n = n(n − 3) . . . . . . . . . . . . . . . .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. M. R. Karimi (SUT) Counting Strategies March 2014 . .. . . . . .. .. .. 4 / 11 Combinations . Example . Twenty-five of King Arthur’s knights are seated at their customary round table. Three of them are chosen- all choices of three being equally likely-and are sent off to slay a troublesome dragon. What is the probability that at least two of the three were seated next to each other? . Answer 1: n + n(n − 4) = n(n − 3) Answer 2: n(n − 2) − n = n(n − 3) Answer 3: n(n − 3) !!! . . . . . . . . . . . . . . . .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. M. R. Karimi (SUT) Counting Strategies March 2014 . .. . . . . .. .. .. 4 / 11 Combinations . Example . In how many ways can one arrange 5 indistinguishable armchairs and 5 indistinguishable armless chairs around a circular table? Two arrangements are considered the same if one can be obtained from the other by rotation. . . . . . . . . . . . . . . . . .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. M. R. Karimi (SUT) Counting Strategies March 2014 . .. . . . . .. .. .. 5 / 11 Combinations . Example . In how many ways can one arrange 5 indistinguishable armchairs and 5 indistinguishable armless chairs around a circular table? Two arrangements are considered the same if one can be obtained from the other by rotation. . Problem translation: (1 ≤ k ≤ 9) {r1 , . . . , r5 } ≡ {r1 + k, . . . , r5 + k} (mod 10) ⇒ 5k ≡ 0 (mod 10) ⇒ k ≡ {2, 4, 6, 8} (mod 10) ⇒ {r1 , . . . , r5 } = {1, 3, 5, 7, 9} or {2, 4, 6, 8, 10} . . . . . . . . . . . . . . . .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. M. R. Karimi (SUT) Counting Strategies March 2014 . .. . . . . .. .. .. 5 / 11 Combinations . Example . In how many ways can one arrange 5 indistinguishable armchairs and 5 indistinguishable armless chairs around a circular table? Two arrangements are considered the same if one can be obtained from the other by rotation. . Problem translation: (1 ≤ k ≤ 9) {r1 , . . . , r5 } ≡ {r1 + k, . . . , r5 + k} (mod 10) ⇒ 5k ≡ 0 (mod 10) ⇒ k ≡ {2, 4, 6, 8} (mod 10) ⇒ {r1 , . . . , r5 } = {1, 3, 5, 7, 9} or {2, 4, 6, 8, 10} Final answer: (10) 5 M. R. Karimi (SUT) −2 2 + 10 2 Counting Strategies . . . . . . . . . . . . . . . .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. March 2014 . .. . . . . .. .. .. 5 / 11 Combinatorical Identities . Theorem (Chu Shih-Chieh’s Identity) . (a) For all r, n ∈ N, n ≥ r we have ( ) ( ) ( ) ( ) r r+1 n n+1 + + ··· + = r r r r+1 (a) For all r, k ∈ N we have ( ) ( ) ( ) ( ) r r+1 r+k r+k+1 + + ··· + = 0 1 k k . . . . . . . . . . . . . . . . .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. M. R. Karimi (SUT) Counting Strategies March 2014 . .. . . . . .. .. .. 6 / 11 Bijections . Example . Let n be an integer n ≥ 2, and define the sequence S = (1, 2, . . . , n). A sub-sequence of S is called arithmetic if it has at least two terms and it is an arithmetic progression. An arithmetic sub-sequence is called maximal if this progression cannot be lengthened by the inclusion of another element of S. Determine the number of maximal arithmetic .sub-sequences. . . . . . . . . . . . . . . . .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. M. R. Karimi (SUT) Counting Strategies March 2014 . .. . . . . .. .. .. 7 / 11 Bijections . Example . Let n be an integer n ≥ 2, and define the sequence S = (1, 2, . . . , n). A sub-sequence of S is called arithmetic if it has at least two terms and it is an arithmetic progression. An arithmetic sub-sequence is called maximal if this progression cannot be lengthened by the inclusion of another element of S. Determine the number of maximal arithmetic .sub-sequences. Solution outline: Each arithmetic progression can be distinguished by a pair (a, d), where a is the first element of this progression, and d is difference between two consecutive elements. . . . . . . . . . . . . . . . .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. M. R. Karimi (SUT) Counting Strategies March 2014 . .. . . . . .. .. .. 7 / 11 Bijections . Example . Let n be an integer n ≥ 2, and define the sequence S = (1, 2, . . . , n). A sub-sequence of S is called arithmetic if it has at least two terms and it is an arithmetic progression. An arithmetic sub-sequence is called maximal if this progression cannot be lengthened by the inclusion of another element of S. Determine the number of maximal arithmetic .sub-sequences. Solution outline: Each arithmetic progression can be distinguished by a pair (a, d), where a is the first element of this progression, and d is difference between two consecutive elements. 1 ≤ a ≤ ⌊ n2 ⌋ and a ≤ d ≤ n − a. So the answer is . . . . . . . . . . . . . . . .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. M. R. Karimi (SUT) Counting Strategies March 2014 . .. . . . . .. .. .. 7 / 11 Bijections . Example . Let n be an integer n ≥ 2, and define the sequence S = (1, 2, . . . , n). A sub-sequence of S is called arithmetic if it has at least two terms and it is an arithmetic progression. An arithmetic sub-sequence is called maximal if this progression cannot be lengthened by the inclusion of another element of S. Determine the number of maximal arithmetic .sub-sequences. Solution outline: Each arithmetic progression can be distinguished by a pair (a, d), where a is the first element of this progression, and d is difference between two consecutive elements. 2 1 ≤ a ≤ ⌊ n2 ⌋ and a ≤ d ≤ n − a. So the answer is ⌊ n4 ⌋ . . . . . . . . . . . . . . . .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. M. R. Karimi (SUT) Counting Strategies March 2014 . .. . . . . .. .. .. 7 / 11 Bijections . Theorem . Combinatorial Equation Number of integer solutions to the equation x1 + x2 + · · · + xk = n, equals to . xi ≥ 0 ( ) n+k−1 k−1 . . . . . . . . . . . . . . . .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. M. R. Karimi (SUT) Counting Strategies March 2014 . .. . . . . .. .. .. 8 / 11 Bijections . Example . In how many ways we can make a “suitable” parentheses configuration with n ‘(’s and n ‘)’s? AKA Catalan Number . . . . . . . . . . . . . . . . .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. M. R. Karimi (SUT) Counting Strategies March 2014 . .. . . . . .. .. .. 9 / 11 Bijections . Example . In how many ways we can make a “suitable” parentheses configuration with n ‘(’s and n ‘)’s? AKA Catalan Number . Solution idea: problem ⇔ Path from (0, 0) to (2n, 0) with moves to NE and SE, not going below y = 0 line. . . . . . . . . . . . . . . . .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. M. R. Karimi (SUT) Counting Strategies March 2014 . .. . . . . .. .. .. 9 / 11 Bijections . Example . In how many ways we can make a “suitable” parentheses configuration with n ‘(’s and n ‘)’s? AKA Catalan Number . Solution idea: problem ⇔ Path from (0, 0) to (2n, 0) with moves to NE and SE, not going below y = 0 line. Make each “bad” path to a “general” path (in a (n − 1) × (n + 1) grid) . . . . . . . . . . . . . . . .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. M. R. Karimi (SUT) Counting Strategies March 2014 . .. . . . . .. .. .. 9 / 11 Bijections . Example . In how many ways we can make a “suitable” parentheses configuration with n ‘(’s and n ‘)’s? AKA Catalan Number . Solution idea: problem ⇔ Path from (0, 0) to (2n, 0) with moves to NE and SE, not going below y = 0 line. Make each “bad” to )a “general” (2n)path ( 2n (2n) path (in a (n − 1) × (n + 1) grid) 1 Final answer: n − n−1 = n+1 n . . . . . . . . . . . . . . . .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. M. R. Karimi (SUT) Counting Strategies March 2014 . .. . . . . .. .. .. 9 / 11 Recursion . Example . Give a recursive representation of the previous problem, then prove the recursion formula by induction (you already know the answer!) . . . . . . . . . . . . . . . . .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. M. R. Karimi (SUT) Counting Strategies March 2014 . .. . . . . .. .. .. 10 / 11 Recursion . Example . Give a recursive representation of the previous problem, then prove the recursion formula by induction (you already know the answer!) . Solution: Let Cn be the answer. We have (the first intersection with y = 0 is at 2k) n ∑ Cn = Ck Cn−k k=1 . . . . . . . . . . . . . . . .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. M. R. Karimi (SUT) Counting Strategies March 2014 . .. . . . . .. .. .. 10 / 11 Recursion . Example . Give a recursive representation of the previous problem, then prove the recursion formula by induction (you already know the answer!) . Solution: Let Cn be the answer. We have (the first intersection with y = 0 is at 2k) n ∑ Cn = Ck Cn−k k=1 Induction, too hard to solve! . . . . . . . . . . . . . . . .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. M. R. Karimi (SUT) Counting Strategies March 2014 . .. . . . . .. .. .. 10 / 11 Happy New Year!! . . . . . . . . . . . . . . . .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. M. R. Karimi (SUT) Counting Strategies March 2014 . .. . . . . .. .. .. 11 / 11
© Copyright 2025 Paperzz