Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Click on the picture Main Menu (Click on the topics below) Combinatorics Introduction Equally likely Probability Formula Counting elements of a list Counting elements of a sublist Sum of numbers from 1 to n Pairs of numbers Possibility Trees & The Multiplication Rule Cartesian Product Subsets of A= {a1, a2,…, an} 3 digit numbers with distinct digits Relations from A to B 3 digit +ve odd integers with distinct digits Combinatorics Counting the number of possible outcomes. Counting the number of ways a task can be done. Sanjay Jain, Lecturer, School of Computing Click on the picture Introduction Multiplication Rule Examples Sanjay Jain, Lecturer, School of Computing Combinatorics Counting Probability To say that a process is random means that when it takes place, one out of a possible set of outcomes will occur. However it is in general impossible to predict with certainty which of the possible outcomes will occur. A sample space is the set of all possible outcomes of a random experiment. An event is a subset of a sample space. Example Tossing two coins. Sample Space: {HH, HT, TH, TT} Event: At least one head: {HH, HT, TH} END OF SEGMENT Equally Likely Probability Formula Suppose S is a sample space in which all outcomes are equally likely. Suppose E is an event in S. Then the probability of E, denoted by Pr(E) is Pr( E ) # (E) # (S ) Notation: For a set A, #(A) denotes the number of elements in A. Sometimes n(A) or || A || is also used for #(A). Sometimes Prob(E) or P(E) is also used for Pr(E). Example Consider the process of drawing a card from a pack of cards. What is the probability of drawing an Ace? Assume drawing any card is equally likely. Sample Space: S={SA, S2, S3, …., HA, H2,….}. Event: E={SA, HA, DA, CA} #(S)=52 #(E)=4 Pr(E)=4/52 END OF SEGMENT Counting The Elements of A List How many integers are there from 8 through 15? 8 9 10 11 12 1 2 3 4 5 13 14 15 6 7 8 Theorem If m and n are integers and m n then there are n-m+1 integers from m to n (both inclusive). Proof: m m+1 m+2 ………………… n m+0 m+1 m+2 …………………m+(n-m) 1 2 3 ……………… (n-m)+1 END OF SEGMENT Counting Elements of a Sublist How many 3 digit positive integers are divisible by 5? 100 105 ………. 995 20*5 21*5 ……… 199*5 20 21 ……….. 199 199 -20+1=180 END OF SEGMENT Floors and Ceilings w denotes the largest integer w. For example: 6.9 = 6; -9.2 = -10; w denotes the smallest integer w. For example: 6.9 =7; -9.2 = -9; 9 = 9 9 = 9 END OF SEGMENT Sum of numbers from 1 to n Theorem: 1+2+….+n = n(n+1)/2 Proof We show this by induction on n. For n=1, the above is clearly true. Suppose the theorem holds for n = k. We show the theorem for n = k+1. 1 + 2 + … + k + (k+1) = [k (k + 1) / 2] + (k+1) = (k + 2) ( k + 1) / 2 = (k + 1) (k + 2) / 2 END OF SEGMENT Pairs of numbers: How many distinct pairs of numbers (i,j) satisfy the property 1 i < j n? For any i, 1 i < n, the number of j’s which satisfy 1 i < j n, is n - i. Thus, the number of distinct pairs of numbers (i,j) that satisfy the property 1 i < j n is n 1 ni = ( n 1) * n i 1 (n 1)n (n 1) * n 2 n 1 i i 1 = ( n 1) n 2 = END OF SEGMENT Possibility Trees Coin Toss: Toss H T 2 ways H 2 x 2 ways T H T END OF SEGMENT The Multiplication Rule Theorem: If an operation (or job) consists of k tasks (or steps), T1, T2,…, Tk, performed one after another and T1 can be done in n1 ways T2 can be done in n2 ways (irrespective of how T1 is done) …. Tk can be done in nk ways (irrespective of how T1 ... Tk-1 are done) Then, the entire operation can be done in n1* n2* ….* nk ways. The Multiplication Rule Theorem: If an operation (or job) consists of k tasks (or steps), T1, T2,…, Tk, performed one after another and Ti can be done in ni ways (irrespective of how T1 ... Ti-1 are done) Caution: Note the independence assumption. One cannot use the multiplication rule unless the independence assumption holds. END OF SEGMENT Cartesian Product How many elements are there in A x B? A= {a1, a2,…., an} B= {b1, b2,…., bm} Recall: A X B = {(a,b) : a A and b B}. Cartesian Product Job: select an element of A X B. T1: Select an element a of A T2: Select an element b of B (this gives us an element (a,b) of A X B) T1 can be done in n ways T2 can be done in m ways (irrespective of how T1 is done) by the multiplication rule, the job can be done in n*m ways. The number of elements of A x B is n*m END OF SEGMENT Subsets of A= {a1, a2,…, an} How many subsets of A={a1, a2,…, an} are there? Job: select a subset of A. T1: either select or not select a1 T2: either select or not select a2 …. Tn: either select or not select an Each of these tasks can be done in two ways (irrespective of how the earlier tasks are done). Thus the number of ways of doing the job is 2n. Therefore, the number of subsets of A is 2n. END OF SEGMENT 3 digit numbers with distinct digits How many 3 digit numbers with distinct digits are there? 3 digit numbers with distinct digits How many 3 digit numbers with distinct digits are there? T1: Select the hundred’s digit T2: Select the ten’s digit T3: Select the unit’s digit 3 digit numbers with distinct digits How many 3 digit numbers with distinct digits are there? T1: Select the hundred’s digit T1 can be done in 9 ways (digit 0 cannot be selected) 3 digit numbers with distinct digits How many 3 digit numbers with distinct digits are there? T2: Select the ten’s digit T2 can be done in 9 ways (irrespective of how T1 was done). You cannot select the digit chosen in T1 3 digit numbers with distinct digits How many 3 digit numbers with distinct digits are there? T3: Select the unit’s digit T3 can be done in 8 ways (irrespective of how earlier tasks were done). You cannot select the digit chosen in T1 and T2 3 digit numbers with distinct digits How many 3 digit numbers with distinct digits are there? T1 can be done in 9 ways T2 can be done in 9 ways T3 can be done in 8 ways Therefore, the total number of 3 digit numbers with distinct digits are 9*9*8 END OF SEGMENT Relations From A to B How many different relations are there from A to B? A={a1, a2,…., an}, B={b1, b2,…., bm} T(i,j) : select or not select (ai,aj) as a member of R. (1 i n and 1 j m) Note that the total number of tasks is n*m. Each T(i,j) can be done in 2 ways. Thus all the tasks can be done in 2n*m ways Total number of relations is: 2n*m Relations From A to B How many different relations are there from A to B? A={a1, a2,…., an}, B={b1, b2,…., bm} Another Method: A relation is a subset of A X B. Number of elements in A X B = n*m number of subsets of A X B = 2n*m END OF SEGMENT Be careful in using the Multiplication Rule How many 3 digit +ve odd integers have distinct digits? T1: Select the hundred’s digit T2: Select the ten’s digit T3: Select the unit’s digit 3 digit +ve odd integers How many 3 digit +ve odd integers have distinct digits? T1: Select the hundred’s digit T1 can be done in 9 ways 3 digit +ve odd integers How many 3 digit +ve odd integers have distinct digits? T2: Select the ten’s digit T2 can be done in 9 ways (irrespective of how T1 was done). You cannot select the digit chosen in T1 3 digit +ve odd integers How many 3 digit +ve odd integers have distinct digits? T3: Select the unit’s digit T3 can be done in ? ways (the number of ways is either 3 or 4 or 5 depending on how exactly T1 and T2 were done). 3 digit +ve odd integers How many 3 digit +ve odd integers have distinct digits? T1 can be done in 9 ways T2 can be done in 9 ways T3 can be done in ? ways Therefore, the Multiplication Rule may not always be applicable. However, for this problem one can use the Multiplication Rule by reordering tasks. 3 digit +ve odd integers How many 3 digit +ve odd integers have distinct digits? (reordering tasks) T1: Select the unit’s digit T2: Select the hundred’s digit T3: Select the ten’s digit 3 digit +ve odd integers How many 3 digit +ve odd integers have distinct digits? (reordering tasks) T1: Select the unit’s digit T1 can be done in 5 ways 3 digit +ve odd integers How many 3 digit +ve odd integers have distinct digits? (reordering tasks) T2: Select the hundred’s digit T2 can be done in 8 ways (irrespective of how T1 was done). 3 digit +ve odd integers How many 3 digit +ve odd integers have distinct digits? (reordering tasks) T3: Select the ten’s digit T3 can be done in 8 ways (irrespective of how T1 and T2 are done). 3 digit +ve odd integers How many 3 digit +ve odd integers have distinct digits? (reordering tasks) T1 can be done in 5 ways T2 can be done in 8 ways T3 can be done in 8 ways Therefore, the total number of 3 digit +ve odd integers with distinct digits is 5*8*8 END OF SEGMENT Symmetric Relations Suppose A ={a1,a2,…,an}. How many symmetric relations can be defined on A? We will show that it is 2n(n+1)/2 Recall: for a relation to be symmetric, for each i, j, either both (ai,aj) and (aj,ai) are in R or both are not in R. Divide the job of selecting a symmetric relation R into the following tasks. Si (for 1 i n) Either select or not select (ai,ai) in R T(i,j) (for 1 i < j n) Either select or not select both (ai,aj) and (aj,ai) in R Note that the number of different T(i,j) 's are (n-1)n/2 Symmetric Relations Si (for 1i n) Either select or not select (ai,ai) in R T(i,j) (for 1i<j n) Either select or not select both (ai,aj) and (aj,ai) in R Each Si and T(i,j) can be done in exactly 2 ways. Thus the total number of symmetric relations on A are (2*2*…*2) * (2*2*….*2) (there are n 2’s in the first group, and ((n-1)n/2) 2’s in the second group) =2n*2n(n-1)/2 =2n(n+1)/2 END OF SEGMENT Simple Graphs How many simple undirected graphs are there with n vertices? This is similar to symmetric relations except that Si’s are not there. T(i,j) (for 1 i < j n) Either select or not select the edge {vi,vj} (= {vj,vi}) Note that the number of different T(i,j) 's are (n-1)n/2 Each T(i,j) can be done in exactly 2 ways. Thus the total number of simple graphs is 2*2*….*2 (there are ((n-1)n/2) 2’s ) =2n(n-1)/2 END OF SEGMENT Click on the picture Summary Multiplication Rule Remember the conditions under which multiplication rule is applicable, specially note the independence assumption Click on the picture Follow-Up Explain assignments. List books, articles, electronic sources. If appropriate, give an introduction to the next lecture in the series.