CS 201 Lecture 19 - Counting
CS 201 Lecture 19 - Counting
Kholoud Nairoukh
Department of Computer Science
German-Jordanian University
Lecture 19
• The study of the number of ways to put
things together into various combinations.
• Examples:
– There are 10 red chairs and 12 blue chairs. How
many ways can you pick a chair to sit in?
– The are three front doors and 2 in the back. How
many ways can you enter the house?
– You have a choice of rolling a die or flipping a
coin. How many outcomes are possible?
You must remember before applying this rule to
ensure that the sets are disjoint
Dr. Kholoud Nairoukh
• This rule deals with counting a series of events and
finding all possible outcomes.
• It states that if you have a series of events the
total possible outcomes of that series is the
product (multiplication) of the number of outcomes
in each event.
• Examples
– If you flip a coin three times, how many possible
outcomes of heads and tails do you have?
– If you roll a pair of dice, how many possible
outcomes?
– If you flip a coin and then roll a die, how many
outcomes of the combined event?
Dr. Kholoud Nairoukh
• There are m ways of doing task 1.
• There are n ways of doing task 2.
• Suppose that km of the ways of doing task
1 also simultaneously accomplish task 2.
– Then, the number of ways to accomplish
“Do either task 1 or task 2” is m+n−k.
• Set theory: If A and B are not disjoint, then
|AB|=|A|+|B|−|AB|.
– If they are disjoint, this simplifies to
|A|+|B|.