Lecture # 10 Ds

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 27

Discrete Structures

LECTURE # 10
The Course
Course Title: Discrete structures
Instructor: MUHAMMAD AWAIS
Semester : 1st
Duration: 16 Weeks
Counting Techniques
Product rule

Suppose that a procedure can be broken down into a sequence of


two tasks. If there are n1 ways to do the first task and for each of
these ways of doing the first task, there are n2 ways to do the
second task, then there are n1n2 ways to do the procedure.
Example 1

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

The chairs of an auditorium are to be labeled with an uppercase


English letter followed by a positive integer not exceeding 100.
What is the largest number of chairs that can be labeled differently?
Solution
Solution:
The procedure of labeling a chair consists of two tasks, namely,
assigning to the seat one of the 26 uppercase English letters, and
then assigning to it one of the 100 possible integers. The product rule
shows that there are 26 · 100 = 2600 different ways that a chair can
be labeled. Therefore, the largest number of chairs that can be
labeled differently is 2600.
Example 3

There are 32 microcomputers in a computer center.


Each microcomputer has 24 ports. How many different ports to
a microcomputer in the center are there?
Solution
Solution:
The procedure of choosing a port consists of two tasks, first picking a
microcomputer and then picking a port on this microcomputer.
Because there are 32 ways to choose the microcomputer and 24
ways to choose the port no matter which microcomputer has been
selected, the product rule shows that there are 32 · 24 = 768 ports.
Sum Rule

If a task can be done either in one of n1 ways or in one of n2 ways,


where none of the set of n1 ways is the same as any of the set of n2
ways, then there are n1 + n2 ways to do the task
Example 1
Suppose that either a member of the mathematics faculty or a student
who is a mathematics major is chosen as a representative to a
university committee. How many different choices are there for this
representative if there are 37 members of the mathematics faculty
and 83 mathematics majors and no one is both a faculty member
and a student?
Solution
Solution:
There are 37 ways to choose a member of the mathematics faculty
and there are 83 ways to choose a student who is a mathematics
major. Choosing a member of the mathematics faculty is never the
same as choosing a student who is a mathematics major because
no one is both a faculty member and a student. By the sum rule it
follows that there are 37 + 83 = 120 possible ways to pick this
representative
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.

Sample Space − When we perform an experiment, then the set S of all


possible outcomes is called the sample space. If we toss a coin, the
sample space S={H,T}

Event − Any subset of a sample space is called an event. After tossing a


coin, getting Head on the top is an event.
steps
Steps to find the probability

Step 1 − Calculate all possible outcomes of the experiment.


Step 2 − Calculate the number of favorable outcomes of the
experiment.
Step 3 − Apply the corresponding probability formula.
Example 1
Tossing a coin
If a coin is tossed, there are two possible outcomes −
Heads (H) or Tails (T)

So, Total number of outcomes = 2

Hence, the probability of getting a Head (H)on top is 1/2 and the

probability of getting a Tails (T) on top is 1/2


Example 2
Throwing a Dice
When a dice is thrown, six possible outcomes can be on the top −
1,2,3,4,5,6
.

The probability of any one of the numbers is 1/6

The probability of getting even numbers is 3/6 = 1/2

The probability of getting odd numbers is 3/6 = 1/2


Example 3
Taking Cards From a Deck
From a deck of 52 cards, if one card is picked find the probability of an ace
being drawn and also find the probability of a diamond being drawn.

Total number of possible outcomes − 52

Outcomes of being an ace − 4

Probability of being an ace = 4/52 = 1/13

Probability of being a diamond = 13/52 = 1/4

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy