Top Banner
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
25

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

Dec 28, 2015

Download

Documents

Kimberly Warren
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Discrete Maths Objective to introduce some of the counting rules (product, sum, subtraction, division, pigeonhole) through examples 242-213, Semester 2,

1

Discrete Maths

• Objectiveto introduce some of the counting

rules (product, sum, subtraction, division, pigeonhole) through examples

242-213, Semester 2, 2014-2015

7. Counting

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

2

Overview1. The Product Rule2. The Sum Rule3. Combining the Sum and Product Rules4. The Subtraction Rule5. The Division Rule6. Tree Diagrams7. The Pigeonhole Principle8. More Information

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

3

1. The Product Rule

no. of waysof doing task 1= n1

no. of waysof doing task 2= n2

no. of waysof doing task 1and then task 2

= n1 * n2

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

4

Example 1How 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 = 27 = 128.

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

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

Example 2

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

6

2. The Sum Rule Tasks must not overlap

no. of waysof doing task 1= n1

no. of waysof doing task 2= n2

no. of waysof doing task 1or task 2

= n1 + n2

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

7

ExampleWe 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.

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

8

Examples of "Overlap"

Task 1 Task 2 Overlap or not?

Choose a man Choose a woman No overlap

Choose a mouse Choose a lion No overlap

Choose a woman Choose an ajarn Overlap

Choose a student Choose an ajarn Overlap!(some Ajarn are also Masters/PhD students)

Cannot use the Sum Rule

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

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

and thenor

and then / followed byor

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

10

Example: Counting Internet AddressesIPv4 uses 32 bits. How many Internet

addresses are there?

continued

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

11

1111111 is not available as the netid of a Class A network.

Hostids consisting of all 0s and all 1s are not available in any network.

A: 7 bits A: 24 bits

C: 21 bits C: 8 bits

B: 14 bits B: 16 bits

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

12

Let xA, xB, and xC denote the number of addresses for the classes.To find, xA: 27 − 1 = 127 netids; 224 − 2 = 16,777,214 hostids. xA = 127 * 16,777,214 = 2,130,706,178To find, xB: 214 = 16,384 netids; 216 − 2 = 16,534 hostids xB = 16,384 * 16, 534 = 1,073,709,056To find, xC: 221 = 2,097,152 netids; 28 − 2 = 254 hostids xC = 2,097,152 * 254 = 532,676,608

continued

not 1111111 not 00..00 or 11..11

and then

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

13

Total number of available IPv4 addresses is = xA or xB or xC

= 2,130,706,178 + 1,073,709,056 + 532,676,608 = 3,737,091,842 about 3.7 billionNot Enough!!The IPv6 protocol solves the problem of too few addresses.

continued

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

14

IPv6 uses 128 bits, so can theoretically hold 2128 IP addresses:2128 =

340,282,366,920,938,463,463,374,607,431,768,211,456 = about 340 x 1037 = 340 undecillion addresses

this is about 7.9×1028 times as many as IPv4

But restrictions on the address space reduces it to nearer 2125 == about 4.2×1037 == 42 undecillion

See http://rednectar.net/2012/05/24/ just-how-many-ipv6-addresses-are-there-really/

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

15

4. The Subtraction Rule

no. of waysof doing task 1= n1

no. of waysof doing task 2= n2

no. of ways of doing task 1or task 2

= n1 + n2 – (no. of tasks common to both)

Tasks do overlap

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

16

Subtraction Rule as SetsA = set of ways of doing task 1B = set of ways of doing task 2No. of ways of doing task 1 or task 2:

A B

ways of doing task 1

ways of doing task 2

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

17

Example: Counting 8-Bit StringsHow 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", ...

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

18

Task 1: no. of 8-bit strings thatstart with a "1": 27 = 128

Task 2: no. of 8-bit strings thatend with "00": 26 = 64

Overlap: no. of 8-bit strings that start with "1" and end with "00" : 25 = 32

Total no. of ways: 128 + 64 − 32 = 160

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

19

5. Division RuleA 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?

Job

no. of ways = n . . . . .d ways d ways d ways. . .

Task 1 Task 2 Task ??

No. of tasks = n/d

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

20

6. Tree DiagramsWe can solve counting problems with tree

diagramsa branch represents a possible choicethe leaves represent possible results

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

21

I DiscreteMathsExample

“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?

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

22

Tree Diagram

4 colors 4 4 3 2

5 size choices

Total no of shirts: 4 + 4 + 4 + 3 + 2 = 17

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

23

7. The Pigeonhole PrinciplePigeonhole 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.

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

24

Example: Among 367 people, there must be at least two with the same birthday, because there are at most 366 possible birthdays.

don't forgetleap years!

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

25

8. More Information

• Discrete Mathematics and its ApplicationsKenneth H. RosenMcGraw Hill, 2007, 7th edition• chapter 6, sections 6.1 – 6.2