Download presentation

Presentation is loading. Please wait.

Published byLynne Webb Modified about 1 year ago

1
Discrete Mathematics University of Jazeera College of Information Technology & Design Khulood Ghazal Basics of CountingBasics of Counting

2
The product ruleThe product rule If there are n 1 ways to do task 1, and n 2 ways to do task 2 If there are n 1 ways to do task 1, and n 2 ways to do task 2 Then there are n 1 n 2 ways to do both tasks in sequence Then there are n 1 n 2 ways to do both tasks in sequence This applies when doing the “procedure” is made up of separate tasks This applies when doing the “procedure” is made up of separate tasks We must make one choice AND a second choice We must make one choice AND a second choice

3
Product rule exampleProduct rule example There are 18 math majors and 325 CS majors There are 18 math majors and 325 CS majors How many ways are there to pick one math major and one CS major? How many ways are there to pick one math major and one CS major? Total is 18 * 325 = 5850 Total is 18 * 325 = 5850

4
The sum ruleThe sum rule If there are n 1 ways to do task 1, and n 2 ways to do task 2 If there are n 1 ways to do task 1, and n 2 ways to do task 2 If these tasks can be done at the same time, then… If these tasks can be done at the same time, then… Then there are n 1 +n 2 ways to do one of the two tasks Then there are n 1 +n 2 ways to do one of the two tasks We must make one choice OR a second choice We must make one choice OR a second choice

5
Sum rule exampleSum rule example There are 18 math majors and 325 CS majors There are 18 math majors and 325 CS majors How many ways are there to pick one math major or one CS major? How many ways are there to pick one math major or one CS major? Total is 18 + 325 = 343 Total is 18 + 325 = 343

6
More complex counting problemsMore complex counting problems We combining the product rule and the sum rule We combining the product rule and the sum rule Thus we can solve more interesting and complex problems Thus we can solve more interesting and complex problems

7
Example(1): The chairs of an auditorium are to be labeled with a letter and a positive integer not exceeding 100. What is the largest number of chairs that can be labeled differently?

8
We can think of this problem as involving a sequence of two tasks: ▪Assign a letter between A and Z ▪Assign a number between 1 and 100 The Product Rule says that there are 26 * 100 = 2600 ways to do this. So we can label 2600 chairs.

9
Example(2): How many different license plates are available if each plate contains a sequence of three letters followed by three digits? –26 choices for each letter –10 choices for each digit –Total of: 26 * 26 * 26 * 10 * 10 * 10

10
Example(3): How many different bit strings are there of length seven? You probably already know it is 2 7. Think of this as: 2 (2 (2 (2 (2 (2 * 2)))))

11
Example(4): How many different bit strings are there of length 1? Only 2: 0 or 1 How many different bit strings are there of length 2? There are 4: 00, 01, 10, 11 How many different bit strings are there of length 3? There are 8: 000, 001, 010, 011, 100, 101, 110, 111

12
Example(5): Each user on a computer system has a password –Each password is six to eight characters long –Each character is an uppercase letter or a digit –Each password must contain at least one digit How many possible passwords are there?

13
There are 26 letters and 10 decimal digits = 36 characters that we can use to form passwords. For P 6 (6-character) passwords, the Product Rule says there are 36 6 potential passwords. But passwords that are all letters are prohibited. There are 26 6 of these. So there are 36 6 – 26 6 for P 6 passwords. Similarly, for P 7 and P 8 passwords. P 7 = 36 7 – 26 7 P 8 = 36 8 – 26 8 Total passwords = P 6 + P 7 + P 8

14
How many bit strings of length eight either start with a 1 or end with the two bits 00? –1st Task: Construct a string beginning with a 1. –2nd Task: Construct a string ending with 00. –Both tasks: Construct a string that begins with a 1 and ends with 00. Example(6):

15
2nd: Construct a string ending with 00. –The product rule says there are 2 ways to choose the first 6 bits and 1 way to chose the last 2 bits, so there are 2 6 ways to construct this string. Both: Construct a string that begins with 1 and ends with 00. –The product rule says there is 1 way to choose the first bit, 2 ways to chose the middle 5 bits, and 1 way to chose the last 2 bits, so there are 2 5 ways to construct this string. Total = (2 7 + 2 6 ) – 2 5 = 160 1 st : There are 2 8 ways to construct a binary string of 8 bits, but it starts with a 1, so there are 2 7 ways to construct an 8- bit binary string starting with 1.

16
Example(7): A multiple choice test contains 10 questions. There are four possible answers for each question. –How many ways can a student answer the questions on the test if every question is answered? –4*4*4*4*4*4*4*4*4*4 = 4 10 –How many ways can a student answer the questions on the test if the student can leave answers blank? –5*5*5*5*5*5*5*5*5*5 = 5 10

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google