Discrete Mathematics 5. COMBINATORICS Lecture 8 Dr.-Ing. Erwin Sitompul

Presentation on theme: "Discrete Mathematics 5. COMBINATORICS Lecture 8 Dr.-Ing. Erwin Sitompul"— Presentation transcript:

Discrete Mathematics 5. COMBINATORICS Lecture 8 Dr.-Ing. Erwin Sitompul http://zitompul.wordpress.com

8/2 Erwin SitompulDiscrete Mathematics Homework 7 Determine GCD(216,88) and express the GCD as a linear combination of 216 and 88. No.1: No.2: Given the ISBN-13: 978-0385510455, check whether the code is valid or not. Hint: Verify the check digit of the ISBN numbers.

8/3 Erwin SitompulDiscrete Mathematics Solution of Homework 7 No.1: By enumerating:  Divisors of 216: 1,2,3,4,6,8,9,12,18,24,27,36,54,72,108.  Divisors of 88: 1,2,4,8,11,22,44.  Common divisors of 216 and 88 are 1, 2, 4, 8. GCD(45,36) = 8. By using Euclidean Algorithm : 216= 88  2 + 40 88 = 40  2 + 8 40= 8  5 + 0 n = 0  m = 8 is the GCD, GCD(216,88) = 8.

8/4 Erwin SitompulDiscrete Mathematics Solution of Homework 7 No.1: Apply Euclidean Algorithm and obtain GCD(216,88) = 8 as follows: 216= 2  88 + 40 (1) 88 = 2  40 + 8 (2) 40= 5  8 + 0 (3) Rearrange (2) to 8 = 88 – 2  40(4) Rearrange (1) to 40= 216 – 2  88(5) Insert (5) to (4) so that 8 = 88 – 2  (216 – 2  88) = 88 – 2  216 + 4  88 = 5  88 – 2  216 Thus, GCD(216, 88) = 8 = 5  88 – 2  216 = –2  216 + 5  88

8/5 Erwin SitompulDiscrete Mathematics Solution of Homework 7 No.2: ISBN-13: 978-0385510455. Assuming the first 12 characters are true, the check digit of a valid ISBN can be obtained as follows: 9  1 + 7  3 + 8  1 + 0  3 + 3  1 + 8  3 + 5  1 + 5  3 + 1  1 + 0  3 + 4  1 + 5  3 = 105 Thus, the check digit is 105 + x 13  0 (mod 10) x 13 =5 The result is identical with the check digit of the ISBN, which is 5. Then, the ISBN is valid.

8/6 Erwin SitompulDiscrete Mathematics  A password may consist of 6 up to 8 characters. The characters can be letters or numbers. How many possible password can be generated? abcdef abcdeg a123bc … resnick mdrosen … zzzzzzzz Password Possibilities

8/7 Erwin SitompulDiscrete Mathematics Definition of Combinatorics  Combinatorics is a branch of mathematics concerning the study of finite or countable discrete structures.  One aspect of combinatorics is counting the number of possible structures of a given kind and size without enumeration.  This is done by deciding when certain criteria can be met, and followed by constructing and analyzing objects meeting the criteria.

8/8 Erwin SitompulDiscrete Mathematics Basic Rules  Rule of Product Attempt 1: p ways Attempt 2: q ways Attempt 1 and attempt 2: p  q ways  Rule of Sum Attempt 1: p ways Attempt 2: q ways Attempt 1 or attempt 2: p + q ways

8/9 Erwin SitompulDiscrete Mathematics Basic Rules Example: A leader of 6 th class in SDN 01 Cikarang will be elected out of 35 male students and 15 female students. In how many ways can the class leader be elected? Solution: By using Rule of Sum, 35 + 15 = 50 ways. Example: The 6 th class in SDN 01 Cikarang is ordered to participate on the traditional costume parade in next August 17. Two students will be chosen to join the parade, one male and one female student. In how many ways can the two representatives be chosen? Solution: By using Rule of Product, 35  15 = 525 ways.

8/10 Erwin SitompulDiscrete Mathematics Extension of Basic Rules  Suppose there are n attempts, and each i-th attempt can be done in p i different ways. then:  Rule of Product For n attempts, the outcome can be obtained in p 1  p 2  …  p n ways.  Rule of Sum For n attempts, the outcome can be obtained in p 1 + p 2 + … + p n ways.

8/11 Erwin SitompulDiscrete Mathematics Example: A binary digit (bit) is constructed by 0 or 1. How many bit strings can be constructed if: (a) The length of the string is 5 digit. (b) The length of the string is 8 digit (= 1 byte). Solution: (a) 2  2  2  2  2 = 2 5 = 32 strings. (b) 2 8 = 256 strings. Extension of Basic Rules

8/12 Erwin SitompulDiscrete Mathematics Extension of Basic Rules Example: How many odd integers are there between 1000 and 9999 (including 1000 and 9999), if: (a) The integers are made of distinct numbers? (b) The integers may be made of the same numbers? Solution: (a) Unit digit: 5 possible numbers (1,3,5,7,9). Thousands digit:8 possible numbers (1 taken, no 0). Hundreds digit: 8 possible numbers (2 taken). Tens digit: 7 possible numbers (3 taken). The amount of possible odd integers are: 5  8  8  7 = 2240. (b)Unit digit : 5 possible numbers (1,3,5,7,9). Thousands digit:9 possible numbers (1-9, no 0). Hundreds digit: 10 possible numbers (0-9). Tens digit: 10 possible numbers (0-9). The amount of possible odd integers are 5  9  10  10 = 4500.

8/13 Erwin SitompulDiscrete Mathematics Extension of Basic Rules Example: The password in a certain computer network is 6- up to 8-character long. The character can be capital letters (A-Z) or numbers (0-9). How many password can be made for this network? Solution: Number of possible characters for the password = 26 (A-Z) + 10 (0-9) = 36 characters. Number of possible 6-character-long passwords: 36  36  36  36  36  36 = 36 6 = 2.176.782.336 Number of possible 7-character-long passwords : 36  36  36  36  36  36  36 = 36 7 = 78.364.164.096 Number of possible 8-character-long passwords : 36  36  36  36  36  36  36  36 = 36 8 = 2.821.109.907.456 Total number of possible passwords (Rule of Sum): 2.176.782.336 + 78.364.164.096 + 2.821.109.907.456 = 2.901.650.853.888.

8/14 Erwin SitompulDiscrete Mathematics Extension of Basic Rules Example: Every byte consists of 8 bits (binary digits). How many bytes begin with ‘11’ or end with ‘11’? Solution: Suppose A = Set of bytes beginning with ’11’, B = Set of bytes ending with ‘11’. then A  B = Set of bytes starting and ending with ‘11’, A  B = Set of bytes starting or ending with ‘11’.  A  = 2 6 = 64,  B  = 2 6 = 64,  A  B  = 2 4 = 16. then  A  B  =  A  +  B  –  A  B  = 64 + 64 – 16 = 112.

8/15 Erwin SitompulDiscrete Mathematics Permutation In how many distinct sequences can the balls (red, blue, white) be placed in the boxes 1, 2, and 3?

8/16 Erwin SitompulDiscrete Mathematics Permutation r bw wb b rw wr w rb br The number of possible ball placements with distinct sequence is 3  2  1 = 3! = 6. Box 1Box 2Box 3

8/17 Erwin SitompulDiscrete Mathematics Permutation  Definition: Permutation is understood to be a sequence containing each element of a finite set, once and only once.  Permutation is a special form of Rule of Product.  Suppose there are n elements in a set, then First place is chosen out of n elements, Second place is chosen out of n – 1 elements, Third place is chosen out of n – 2 elements, … Last place is chosen out of 1 remaining element.  According to Rule of Product, the number of permutations of n elements is: n  (n – 1)  (n – 2)  …  2  1 = n!

8/18 Erwin SitompulDiscrete Mathematics Example: How many letter sequences can be made out of the word “ERASE”? Solution: Way 1: 5  4  3  2  1 = 120 sequences. Way 2: P(5,5) = 5! = 120 sequences. Permutation Example: In how many different ways can an attendance list be made, if the number of students in a class is 25? Solution: P(25,25) = 25! ≈ 1.551  10 25 different ways.

8/19 Erwin SitompulDiscrete Mathematics Permutation r of n Now, there are 6 balls with different color and 3 boxes. Each box can only be filled by one ball. In how many distinct sequences can the balls be placed in the boxes? Solution: Box 1 can be filled by one of 6 balls (6 choices). Box 2 can be filled by one of 5 balls (5 choices). Box 3 can be filled by one of 4 balls (4 choices). Number of distinct sequences = 6  5  4 = 120.

8/20 Erwin SitompulDiscrete Mathematics Permutation r of n If there are n balls with different colors and r boxes (r  n), then First box can be filled by one of n ball  (there are n choices), Second box can be filled by one of (n – 1) balls  (there are n – 1 choice), Third box can be filled by one of (n – 2) balls  (there are n – 2 choice), … The r-th box can be filled by one of (n – (r – 1)) balls  (there are n – r + 1 choices), Number of distinct sequences in placing the balls is : n  (n – 1)  (n – 2)  …  (n – (r – 1)).

8/21 Erwin SitompulDiscrete Mathematics Permutation Formula Permutation of r out of n different objects is the number of possible sequences of r objects which are taken out of n available objects, with the condition r  n.

8/22 Erwin SitompulDiscrete Mathematics Example: How many possible hundreds number can be formed by using the first five positive integers 1, 2, 3, 4, and 5, if: (a) Each number may only used once (no repetition)? (b) Each number may be used more than once (repetition is allowed)? Solution: (a)By Rule of Product: 5  4  3 = 60. By Permutation Formula P(5,3) = 5!/(5 – 3)! = 60. (b)By Rule of Product: 5  5  5 = 5 3 = 125. Cannot be solved by using Permutation Formula (it is not a permutation). Permutation

8/23 Erwin SitompulDiscrete Mathematics Permutation Example: The book code in a library consists of 7 characters, with 4 distinct letters followed by 3 distinct numbers. How many book code can be made according to this rule? Solution: P(26,4)  P(10,3) = 26!/(26 – 4)!  10!/(10 – 3)! = 26  25  24  23  10  9  8 = 258.336.000.

8/24 Erwin SitompulDiscrete Mathematics Combination  Combination is a specific form of permutation.  If in permutation the order matters, then in combination the order does not matter.  Combination is understood to be a sequence containing elements of a finite set

8/25 Erwin SitompulDiscrete Mathematics r bw wb b rw wr w rb br  In combination, the order of appearance is neglected.  The number of distinct combinations in placing 3 balls in 3 boxes is 1 = P(3,3)/3! Box 1Box 2Box 3 Combination rbw = rwb = brw = bwr = wrb = wbr

8/26 Erwin SitompulDiscrete Mathematics Combination  The number of distinct combinations (that is, without regarding the order) in placing 3 out of 7 balls in 3 boxes is 20 = P(6,3)/3! (Check by enumerating!)  A mix of 3 balls with different colors is only counted as 1 one combination only.

8/27 Erwin SitompulDiscrete Mathematics Combination Formula In general, the number of ways to put r colored balls in n boxes, without regarding the order of the balls when they are taken and put, is can also be written as Combination of r out of n objects, or C(n,r), is the number of unordered choices of r objects taken out of n.

8/28 Erwin SitompulDiscrete Mathematics Interpretation of Combination  C(n,r) is the number of subsets consisting r elements/members, which are made out of a set with n elements/members.  Suppose A = { 1,2,3,4 }.  Subsets with 3 elements/members are: { 1,2,3 } = { 1,3,2 } = { 2,1,3 } = { 2,3,1 } = { 3,1,2 } = { 3,2,1 } { 1,2,4 } = { 1,4,2 } = { 2,1,4 } = { 2,4,1 } = { 4,1,2 } = { 4,2,1 } { 1,3,4 } = { 1,4,3 } = { 3,1,4 } = { 3,4,1 } = { 4,1,3 } = { 4,3,1 } { 2,3,4 } = { 2,4,3 } = { 3,2,4 } = { 3,4,2 } = { 4,2,3 } = { 4,3,2 }  Thus, there are 4 subsets which are distinct to each other, or

8/29 Erwin SitompulDiscrete Mathematics Combination Example: Commission IV of DPR RI consists of 25 members. In how many ways can a special committee be formed, if the size of the committee is 5 people? Solution: From the available information, a special committee is a group of members where order does not matter. The members of the special committee have equal position. C(25,5)= 25!/((25 – 5)!5!) = 25  24  23  22  21/(5  4  3  2  1) = 53.130

8/30 Erwin SitompulDiscrete Mathematics Combination Example: Among 10 IT students batch 2009, a 5-member representative committee will be formed. Encep and Florina are calculating their chance to be elected. In how many ways can the committee be formed such that: (a)Encep is elected. (b) Encep is not elected. (c) Encep is elected but Florina not. (d) Florina is elected but Encep not. (e)Encep and Florina are elected. (f) At least one of them is elected.

8/31 Erwin SitompulDiscrete Mathematics Combination Solution: (a) Encep is elected. (b) Encep is not elected. (c) Encep is elected but Florina not.

8/32 Erwin SitompulDiscrete Mathematics Combination Solution: (d) Florina is elected but Encep not. (e) Encep and Florina are elected. (f) At least one of them is elected. Identical to the answer of (c) Encep elected, Florina not Florina elected, Encep not Both of them elected

8/33 Erwin SitompulDiscrete Mathematics Solution: (f) At least one of them is elected. Combination  Part (f) can also be solved by using Inclusion-Exclusion Principle.  Assume X = Number of ways to form a representative that includes Encep, Y = Number of ways to form a representative that includes Florina, X  Y= Number of ways to form a representative that includes both Encep and Florina.  Then  X  = C(9,4) = 126  Y  = C(9,4) = 126  X  Y  = C(8,3) = 56  X  Y  =  X  +  Y  –  X  Y  = 126 + 126 – 56 = 196.

8/34 Erwin SitompulDiscrete Mathematics Homework 8 A chairperson and a treasurer of PUMA IE should be chosen out of 50 eligible association members. In how many ways can a chairperson and a treasurer can be elected, if: (a)There is no limitation. (b) Amir wants to serve only if elected as a chairperson. (c) Budi and Cora want to be elected together or not at all. (d) Dudi and Encep do not want to work together.

8/35 Erwin SitompulDiscrete Mathematics Homework 8 New A vehicle registration plate in greater Jakarta area contains 3 letters since the end of 2009. This is due to the increase of motorized vehicles in the area. (a)Before, how many registration plates are available (when only 2 letters are used)? (b) Afterwards, how many registration plates are available (with 3 letters used). Hint: Assume that there is no restrictions to arrage the letters and numbers.