Lecture # 10 Ds
Lecture # 10 Ds
Lecture # 10 Ds
LECTURE # 10
The Course
Course Title: Discrete structures
Instructor: MUHAMMAD AWAIS
Semester : 1st
Duration: 16 Weeks
Counting Techniques
Product rule
A new company with just two employees, Ahmad and Ali, rents
a floor of a building with 12 offices. How many ways are there to
assign different offices to these two employees?
Solution
Solution:
The procedure of assigning offices to these two employees
consists of assigning an office to ali, which can be done in 12
ways, then assigning an office to ahmad different from the office
assigned to ali, which can be done in 11 ways. By the product
rule, there are 12 · 11 = 132 ways to assign offices to these two
employees.
Example 2
A student can choose a computer project from one of three lists. The
three lists contain 23, 15, and 19 possible projects, respectively. No
project is on more than one list. How many possible projects are
there to choose from?
Solution
Solution:
The student can choose a project by selecting a project from the first
list, the second list, or the third list. Because no project is on more
than one list, by the sum rule there are 23 + 15 + 19 = 57 ways to
choose a project.
Example 3
What is the value of k after the following code, where n1, n2,...,nm
are positive integers, has been executed?
Solution
The initial value of k is zero. This block of code is made up of m
different loops. Each time a loop is traversed, 1 is added to k. To
determine the value of k after this code has been executed, we need
to determine how many times we traverse a loop. Note that there are
ni ways to traverse the ith loop. Because we only traverse one loop at
a time, the sum rule shows that the final value of k, which is
the number of ways to traverse one of the m loops is n1 + n2 +···+ nm
Subtract rule
If a task can be done in either n1 ways or n2 ways, then the number
of ways to do the task is n1 + n2 minus the number of ways to do the
task that are common to the two different ways. The subtraction rule
is also known as the principle of inclusion–exclusion, especially when
it is used to count the number of elements in the union of two sets.
Example
Suppose that A1 and A2 are sets. Then, there are |A1| ways to select
an element from A1 and |A2| ways to select an element from A2. The
number of ways to select an element from A1 or from A2, that is, the
number of ways to select an element from their union, is the sum of
the number of ways to select an element from A1 and the number of
ways to select an element from A2, minus the number of ways to select
an element that is in both A1 and A2. Because there are |A1 ∪ A2|
ways to select an element in either A1 or in A2, and |A1 ∩ A2| ways to
select an element common to both sets, we have
|A1 ∪ A2|=|A1|+|A2|−|A1 ∩ A2|.
Probability
Probability
The word 'Probability' means the chance of occurring of a particular
event. It is generally possible to predict the future of an event
quantitatively with a certain probability of being correct. The probability
is used in such cases where the outcome of the trial is uncertain.
Probability Definition:
The probability of happening of an event A, denoted by P(A), is defined
as
Random Experiment − An experiment in which all possible outcomes are
known and the exact output cannot be predicted in advance is called a
random experiment. Tossing a fair coin is an example of random
experiment.
Hence, the probability of getting a Head (H)on top is 1/2 and the