Presentation is loading. Please wait.

Presentation is loading. Please wait.

Counting CSC-2259 Discrete Structures Konstantin Busch - LSU1.

Similar presentations


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

1 Counting CSC-2259 Discrete Structures Konstantin Busch - LSU1

2 Basic Counting Principles Konstantin Busch - LSU2 Product Rule: Suppose a procedure consists of 2 tasks ways to perform 1 st task ways to perform 2 nd task ways to perform procedure

3 Konstantin Busch - LSU3 Example:2 employees10 offices How many ways to assign employees to offices? 1 st employee has 10 office choices 2 nd employee has 9 office choices Total office assignment ways: 10x9 = 90

4 Konstantin Busch - LSU4 Example:How many different variable names with 2 symbols? 1 st symbol letter 26 choices 2 nd symbol alphanumeric 26+10 = 36 choices Total variable name choices: 26x36 = 936 (e.g. A1, A2, AA)

5 Konstantin Busch - LSU5 Generalized Product Rule: Suppose a procedure consists of tasks ways to perform 1 st task ways to perform 2 nd task ways to perform procedure ways to perform th task

6 Konstantin Busch - LSU6 Example:How many different variable names with exactly symbols? 1 st symbol letter 26 choices Remaining symbols alphanumeric 36 choices for each Total choices: (e.g. D1B…6)

7 Konstantin Busch - LSU7 Sum Rule: Suppose a procedure can be performed with either of 2 different methods ways to perform 1 st method ways to perform 2 nd method ways to perform procedure

8 Konstantin Busch - LSU8 Example: Number of variable names with 1 or 2 symbols Variables with 1 symbol: 26 Variables with 2 symbols: 936 Total number of variables: 26+936=962

9 Konstantin Busch - LSU9 Principle of Inclusion-Exclusion: Suppose a procedure can be performed with either of 2 different methods ways to perform 1 st method ways to perform 2 nd method ways to perform procedure common ways in both methods

10 Konstantin Busch - LSU10 Example: Number of binary strings of length 8 that either start with 1 or end with 0 Strings that start with 1: Strings that end with 0: Total strings: 128+128-64=192 128 choices Common strings: 64 choices

11 Pigeonhole Principle Konstantin Busch - LSU11 3 pigeons2 pigeonholes

12 Konstantin Busch - LSU12 One pigeonhole contains 2 pigeons 3 pigeons2 pigeonholes

13 Konstantin Busch - LSU13 k+1 pigeonsk pigeonholes

14 Konstantin Busch - LSU14 At least one pigeonhole contains 2 pigeons k+1 pigeonsk pigeonholes

15 Konstantin Busch - LSU15 Pigeonhole Principle: If k+1 objects are placed into k boxes, then at least one box contains 2 objects Examples: Among 367 people at least 2 have the same birthday (366 different birthdays) Among 27 English words at least 2 start with same letter (26 different letters)

16 Konstantin Busch - LSU16 Generalized Pigeonhole Principle: If objects are placed into boxes, then at least one box contains objects Proof: If each box contains less than objects: End of Proof contradiction

17 Konstantin Busch - LSU17 Example: Among people, at least have birthday in same month people (objects) months (boxes)

18 Konstantin Busch - LSU18 Example: How many students do we need to have so that at least six receive same grade (A,B,C,D,F)? students (objects) grades (boxes) at least six students receive same grade

19 Konstantin Busch - LSU19 Smallest integer with is smallest integer with

20 Konstantin Busch - LSU20 For our example: students We need at least 26 students

21 Konstantin Busch - LSU21 An elegant example: In any sequence of numbers there is a sorted subsequence of length (ascending or descending) 8, 11, 9, 1, 4, 6, 12, 10, 5, 7 Ascending subsequence Descending subsequence

22 Konstantin Busch - LSU22 Theorem: In any sequence of numbers there is a sorted subsequence of length (ascending or descending) Proof: Length of longest ascending subsequence starting from Sequence Length of longest descending subsequence starting from

23 Konstantin Busch - LSU23 8, 11, 9, 1, 4, 6, 12, 10, 5, 7 Longest ascending subsequence from Longest descending subsequence from For example:

24 Konstantin Busch - LSU24 8, 11, 9, 1, 4, 6, 12, 10, 5, 7 Longest ascending subsequence from Longest descending subsequence from For example:

25 We want to prove that there is a with: Konstantin Busch - LSU25 Suppose (for contradiction) that for every : or and

26 Konstantin Busch - LSU26 Number of unique pairs of form with and : unique pairs choices For example:

27 Konstantin Busch - LSU27 unique pairs of form Since has elements there are exactly pairs of form From pigeonhole principle, there are two equal pairs and

28 Konstantin Busch - LSU28 Case : Ascending subsequence with elements Ascending subsequence with elements Contradiction, since longest ascending subsequence from has length

29 Konstantin Busch - LSU29 Case : Descending subsequence with elements Descending subsequence with elements Contradiction, since longest descending subsequence from has length End of Proof

30 Permutations Konstantin Busch - LSU30 Permutation: Objects: a,b,c An ordered arrangement of objects Example: Permutations: a,b,c a,c,b b,a,c b,c,a c,a,b c,b,a

31 Konstantin Busch - LSU31 r-permutation: Objects: a,b,c,d An ordered arrangement of r objects Example: 2-permutations: a,b a,c a,d b,a b,c b,d c,a c,b c,d d,a d,b d,c

32 Konstantin Busch - LSU32 How many ways to arrange 5 students in line? 1 st position in line: 5 student choices 2 nd position in line: 4 student choices 3 rd position in line: 3 student choices 4 th position in line: 2 student choices 5 th position in line: 1 student choices Total permutations: 5x4x3x2x1=120

33 Konstantin Busch - LSU33 How many ways to arrange 3 students in line out of a group of 5 students? 1 st position in line: 5 student choices 2 nd position in line: 4 student choices 3 rd position in line: 3 student choices Total 3-permutations: 5x4x3=60

34 Konstantin Busch - LSU34 Given objects the number of -permutations is denoted Examples:

35 Konstantin Busch - LSU35 Theorem: Proof: 1 st position object choices 2 nd position object choices 3 rd position object choices r th position object choices

36 Konstantin Busch - LSU36 End of Proof Multiply and divide with same product

37 Konstantin Busch - LSU37 Example:How many different ways to order gold, silver, and bronze medalists out of 8 athletes?

38 Combinations Konstantin Busch - LSU38 r-combination:An unordered arrangement of r objects Objects: a,b,c,dExample: 2-combinations: a,b a,c a,d b,c b,d c,d 3-combinations: a,b,c a,b,d a,c,d b,c,d

39 Konstantin Busch - LSU39 Given objects the number of -combinations is denoted Examples: or Also known as binomial coefficient

40 Konstantin Busch - LSU40 Combinations can be used to find permutations Objects: a,b,c,d a,b,c a,b,d a,c,d b,c,d 3-combinations

41 Konstantin Busch - LSU41 Combinations can be used to find permutations Objects: a,b,c,d a,b,c a,b,d a,c,d b,c,d a,c,b a,d,b a,d,c b,d,c b,a,c b,a,d c,a,d c,b,d b,c,a b,d,a c,d,a c,d,b c,a,b d,a,b d,a,c d,b,c c,b,a d,b,a d,c,a d,c,b 3-combinations 3-permutations

42 Konstantin Busch - LSU42 Combinations can be used to find permutations 3-combinations 3-permutations a,b,c a,b,d a,c,d b,c,d a,c,b a,d,b a,d,c b,d,c b,a,c b,a,d c,a,d c,b,d b,c,a b,d,a c,d,a c,d,b c,a,b d,a,b d,a,c d,b,c c,b,a d,b,a d,c,a d,c,b Total permutations: Objects: a,b,c,d

43 Konstantin Busch - LSU43 Theorem: Proof: End of Proof

44 Konstantin Busch - LSU44 Example:Different ways to choose 5 cards out of 52 cards

45 Konstantin Busch - LSU45 Observation: Example:

46 Binomial Coefficients Konstantin Busch - LSU46

47 Konstantin Busch - LSU47 Possible ways to obtain product of terms of and terms of Possible ways to obtain product of terms of and terms of Possible ways to obtain product of terms of and terms of

48 Konstantin Busch - LSU48 times Possible ways to obtain product of terms of and terms of Possible ways to obtain product of terms of and terms of Possible ways to obtain product of terms of and terms of

49 Konstantin Busch - LSU49 Observation:

50 Konstantin Busch - LSU50 Observation:

51 Konstantin Busch - LSU51 Observation:

52 Konstantin Busch - LSU52 evenodd

53 Konstantin Busch - LSU53 Pascal’s Identity: Proof:set with elements element of

54 Konstantin Busch - LSU54 number of subsets of with size subsets that contain subsets that do not contain

55 Konstantin Busch - LSU55 :subsets of with size that contain Each has form: elements from Total ways for constructing :

56 elements from Konstantin Busch - LSU56 :subsets of with size that do not contain Each has form: Total ways for constructing :

57 Konstantin Busch - LSU57 End of Proof

58 Konstantin Busch - LSU58 Pascal’s Triangle

59 Generalized Permutations and Combinations Konstantin Busch - LSU59 Permutations with repetition for: a,b,c aaa aab aba abb aac aca acc abc acb bbb bba bab baa bbc bcb bcc bac bca ccc cca cac caa ccb cbc cbb cab cba Total permutations with repetition: 3x3x3 = 27 3 ways to chose each symbol

60 Konstantin Busch - LSU60 Permutations with repetition: #ways to arrange in line objects chosen from a collection of objects: Example: Strings of length from English alphabet: aaaaa, aaaab, aaaba, aaabb, aabab,…

61 Konstantin Busch - LSU61 Combinations with repetition for: a,b,c aaa aab aba abb aac aca acc abc acb bbb bba bab baa bbc bcb bcc bac bca ccc cca cac caa ccb cbc cbb cab cba Total combinations with repetition: 10 aaa aab abb aac acc abc bbb bbc bcc ccc After removing redundant permutations

62 Konstantin Busch - LSU62 a | b | c * * * 1 st letter choice 2 nd letter choice 3 rd letter choice abc = a|b|c = *|*|* aab = aa|b|= **|*| acc = a||cc = *||** bcc =|b|cc = |*|** Encoding for combinations with repetitions:

63 Konstantin Busch - LSU63 All possible combinations with repetitions for objects a,b,c: aaa: ***|| aab: **|*| aac: **||* abb: *|**| abc: *|*|* acc: *||** bbb: |***| bbc: |**|* bcc: |*|** ccc: ||*** Equivalent to finding all possible ways to arrange *** and ||

64 Konstantin Busch - LSU64 All possible ways to arrange *** and || : equivalent to all possible ways to select 2 objects out of 5: 5 total positions in a string 3 positions are dedicated for *

65 Konstantin Busch - LSU65 2-combinations with repetition for: a,b,c Total = 6aa ab ac bb bc cc Each combination can be encoded with ** and || : ab = a|b| = *|*| ac = a||c = *||*

66 Konstantin Busch - LSU66 All possible 2-combinations with repetitions for objects a,b,c: aa: **|| ab: *|*| ac: *||* bb: |**| bc: |*|* cc: ||** Equivalent to finding all possible ways to arrange ** and ||

67 Konstantin Busch - LSU67 All possible ways to arrange ** and || : equivalent to all possible ways to select 2 objects out of 4: 4 total positions in a string 2 positions are dedicated for *

68 Konstantin Busch - LSU68 r-combinations with repetition: Number of ways to select objects out of : Proof: Each of the objects corresponds to a * The original objects create of |

69 Konstantin Busch - LSU69 obj 1|obj 2|obj 3|…|obj(n-1)|obj n *|***|*||*|…|* The | separate the original objects The * represent the selected objects 1 st selected object 2 nd selected object r th selected object

70 Konstantin Busch - LSU70 Each -combination can be encoded with a unique string formed with **…* and ||…| : abc = a|b|c|| = *|*|*|| Example 3-combinations of 5 objects a,b,c,d,e: cde = ||c|d|e = ||*|*|* *|***|*||*|…|* String length:

71 Konstantin Busch - LSU71 All possible strings made of **…* and ||…| : Equivalent to all possible ways to select objects out of : total positions in a string positions are dedicated for * End of Proof

72 Konstantin Busch - LSU72 Example: How many ways to select r=6 cookies from a collection of n=4 different kinds of cookies? Equivalent to combinations with repetition:

73 Konstantin Busch - LSU73 Example:How many integer solutions does the equation have?

74 Konstantin Busch - LSU74 Equivalent to selecting r=11 items (ones) from n=3 kinds (variables)

75 Konstantin Busch - LSU75 Permutations of indistinguishable objects SUCCESS How many different strings are made by reordering the letters in the string? SUSCCES, USCSECS, CESUSSC,…

76 Konstantin Busch - LSU76 SUCCESS available positions for 3 S SUCCESS available positions for 2 C SUCCESS available positions for 1 U SUCCESS available positions for 1 E Total possible strings:

77 Konstantin Busch - LSU77 Permutations of indistinguishable objects: indistinguishable objects of type 1 indistinguishable objects of type 2 indistinguishable objects of type k Total permutations for the objects:

78 Konstantin Busch - LSU78 Proof: Available positions for objects of type 1 Available positions for objects of type 2 Available positions for objects of type k

79 Konstantin Busch - LSU79 Total possible permutations: End of Proof

80 Konstantin Busch - LSU80 Distributing objects into boxes distinguishable objects: a, b, c, d, e distinguishable boxes: Box1: holds 2 objects Box2: holds 1 object Box3: holds 2 objects How many ways to distribute the objects into the boxes? (position inside box doesn’t matter) Box 1Box 2Box 3 c d b a e

81 Konstantin Busch - LSU81 Problem is equivalent to finding all permutations with indistinguishable objects distinct positions: a b c d e a b c d e positions for Box 1 a b c d e positions for Box 2 c d ba e a b c d e positions for Box 3

82 Konstantin Busch - LSU82 Total arrangements of objects into boxes: Same as permutations of indistinguishable objects

83 Konstantin Busch - LSU83 distinguishable objects distinguishable boxes: Box1: holds objects Box2: holds objects … Boxk: holds objects In general: Total arrangements:

84 Konstantin Busch - LSU84 Distributing indistinguishable objects into distinguishable boxes indistinguishable objects distinguishable boxes: … Box 1Box 2Box n ……

85 Konstantin Busch - LSU85 Box 1Box 2Box n …… Problem is same with finding the number of solutions to equation: number of objects in Box

86 Konstantin Busch - LSU86 Total number of solutions: Is equal to number of ways to distribute the indistinguishable objects into the boxes


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

Similar presentations


Ads by Google