Presentation is loading. Please wait.

Presentation is loading. Please wait.

Discrete Maths Objective to introduce some of the counting rules (product, sum, subtraction, division, pigeonhole) through examples 242-213, Semester 2,

Similar presentations


Presentation on theme: "Discrete Maths Objective to introduce some of the counting rules (product, sum, subtraction, division, pigeonhole) through examples 242-213, Semester 2,"— Presentation transcript:

1 Discrete Maths Objective to introduce some of the counting rules (product, sum, subtraction, division, pigeonhole) through examples 242-213, Semester 2, 2014-2015 7. Counting 1

2 Overview 1. The Product Rule 2. The Sum Rule 3. Combining the Sum and Product Rules 4. The Subtraction Rule 5. The Division Rule 6. Tree Diagrams 7. The Pigeonhole Principle 8. More Information 2

3 1. The Product Rule 3 no. of ways of doing task 1 = n 1 no. of ways of doing task 1 = n 1 no. of ways of doing task 2 = n 2 no. of ways of doing task 2 = n 2 no. of ways of doing task 1 and then task 2 = n 1 * n 2 no. of ways of doing task 1 and then task 2 = n 1 * n 2

4 Example 1 How many different 7-bit strings are there? e.g. "1100011", "0001100",... Each bit can be 0 or 1, so no. of ways == 2 for 1 bit. For 7 bits, the no. of ways is 2*2*2*2*2*2*2 = 2 7 = 128. 4

5 How many different car license plates can be made if each plate is three uppercase English letters followed by three digits? There are 26 * 26 * 26 * 10 * 10 * 10 = 17,576,000 5 Example 2

6 2. The Sum Rule 6 Tasks must not overlap no. of ways of doing task 1 = n 1 no. of ways of doing task 1 = n 1 no. of ways of doing task 2 = n 2 no. of ways of doing task 2 = n 2 no. of ways of doing task 1 or task 2 = n 1 + n 2 no. of ways of doing task 1 or task 2 = n 1 + n 2

7 Example We must choose either a man or a woman for a group. How many choices are there if there are 37 men and 83 women? There are 37 + 83 = 120 possible ways. 7

8 Examples of "Overlap" Task 1Task 2Overlap or not? Choose a manChoose a womanNo overlap Choose a mouseChoose a lionNo overlap Choose a womanChoose an ajarnOverlap Choose a studentChoose an ajarnOverlap! (some Ajarn are also Masters/PhD students) 8 Cannot use the Sum Rule

9 3. Combining Sum and Product Rules Example: Variable names in a programming language can be a single letter or a letter followed by a single digit. All letters are lowercase. e.g. "x", "y", "a2", "w3", "b9",... Find the number of possible names. Solution: 26 + ( 26 * 10) = 286 9 and then or and then / followed by or

10 Example: Counting Internet Addresses IPv 4 uses 32 bits. How many Internet addresses are there? 10 continued

11 1111111 is not available as the netid of a Class A network. Hostids consisting of all 0 s and all 1 s are not available in any network. 11 A: 7 bits A: 24 bits C: 21 bits C: 8 bits B: 14 bits B: 16 bits

12 Let x A, x B, and x C denote the number of addresses for the classes. To find, x A : 2 7 − 1 = 127 netids; 2 24 − 2 = 16,777,214 hostids. x A = 127 * 16,777,214 = 2,130,706,178 To find, x B : 2 14 = 16,384 netids; 2 16 − 2 = 16,534 hostids x B = 16,384 * 16, 534 = 1,073,709,056 To find, x C : 2 21 = 2,097,152 netids; 2 8 − 2 = 254 hostids x C = 2,097,152 * 254 = 532,676,608 12 continued not 1111111 not 00..00 or 11..11 and then

13 Total number of available IPv 4 addresses is = x A or x B or x C = 2,130,706,178 + 1,073,709,056 + 532,676,608 = 3,737,091,842 about 3.7 billion 13 Not Enough!! The IPv6 protocol solves the problem of too few addresses. Not Enough!! The IPv6 protocol solves the problem of too few addresses. continued

14 IPv6 uses 128 bits, so can theoretically hold 2 128 IP addresses: 2 128 = 340,282,366,920,938,463,463,374,607,431,768,211,456 = about 340 x 10 37 = 340 undecillion addresses this is about 7.9×10 28 times as many as IPv4 But restrictions on the address space reduces it to nearer 2 125 == about 4.2×10 37 == 42 undecillion See http://rednectar.net/2012/05/24/ just-how-many-ipv6-addresses-are-there-really/ 14

15 4. The Subtraction Rule 15 no. of ways of doing task 1 = n 1 no. of ways of doing task 1 = n 1 no. of ways of doing task 2 = n 2 no. of ways of doing task 2 = n 2 no. of ways of doing task 1 or task 2 = n 1 + n 2 – (no. of tasks common to both) no. of ways of doing task 1 or task 2 = n 1 + n 2 – (no. of tasks common to both) Tasks do overlap

16 Subtraction Rule as Sets A = set of ways of doing task 1 B = set of ways of doing task 2 No. of ways of doing task 1 or task 2: 16 AB ways of doing task 1 ways of doing task 2

17 Example: Counting 8-Bit Strings How many 8-bit strings either start with a " 1" or end with " 00" ? e.g. "10000111", "00111100",... But there is overlap: strings that start with "1" and end with "00": e.g. "10000000", "10110100",... 17

18 Task 1: no. of 8-bit strings that start with a " 1 ": 2 7 = 128 Task 2: no. of 8-bit strings that end with " 00" : 2 6 = 64 Overlap: no. of 8-bit strings that start with " 1 " and end with " 00" : 2 5 = 32 Total no. of ways: 128 + 64 − 32 = 160 18

19 5. Division Rule A big job can be carried out in n ways. It can be divided into separate tasks, each of which can be done in d ways. How many tasks are there? 19 Job no. of ways = n..... d ways... Task 1Task 2 Task ?? No. of tasks = n/d

20 6. Tree Diagrams We can solve counting problems with tree diagrams a branch represents a possible choice the leaves represent possible results 20

21 21 I Discrete Maths Example “I Love Discrete Maths” T-shirts come in five different sizes: S, M, L, XL, and XXL. Each size comes in four colors (white, red, green, and black), except XL, which comes only in red, green, and black, and XXL, which comes only in green and black. What is the minimum number of shirts that a shop needs to have one of each size and color?

22 Tree Diagram 22 4 colors4 4 3 2 5 size choices Total no of shirts: 4 + 4 + 4 + 3 + 2 = 17

23 7. The Pigeonhole Principle Pigeonhole Principle: If k + 1 objects are placed in k boxes, then at least one box contains 2 or more objects. e.g. If 10 pigeons are in 9 pigeonholes, one of the pigeonholes must have more than 1 pigeon. 23

24 Example: Among 367 people, there must be at least two with the same birthday, because there are at most 366 possible birthdays. 24 don't forget leap years!

25 8. More Information Discrete Mathematics and its Applications Kenneth H. Rosen McGraw Hill, 2007, 7th edition chapter 6, sections 6.1 – 6.2 25


Download ppt "Discrete Maths Objective to introduce some of the counting rules (product, sum, subtraction, division, pigeonhole) through examples 242-213, Semester 2,"

Similar presentations


Ads by Google