Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
107 views

Lecture Note - Counting and Combinatorics1

This document provides information about the CSC 413 Discrete Mathematics II course at the University of Lagos. It outlines the course instructors, lecture and lab times, topics to be covered including sets, logic, proofs, relations, counting, combinatorics, and graphs. It also lists the required textbook and notes students should use. The remainder of the document details specific topics in counting and combinatorics, including basic counting principles like the sum and product rules, inclusion-exclusion, permutations, combinations, and the pigeonhole principle.

Uploaded by

Oriola Kolawole
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
107 views

Lecture Note - Counting and Combinatorics1

This document provides information about the CSC 413 Discrete Mathematics II course at the University of Lagos. It outlines the course instructors, lecture and lab times, topics to be covered including sets, logic, proofs, relations, counting, combinatorics, and graphs. It also lists the required textbook and notes students should use. The remainder of the document details specific topics in counting and combinatorics, including basic counting principles like the sum and product rules, inclusion-exclusion, permutations, combinations, and the pigeonhole principle.

Uploaded by

Oriola Kolawole
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 41

CSC 413

Discrete Mathematics II
Course Instructors:
Dr. Victor T. Odumuyiwa
Dr. Ufuoma C. Ogude

Department of Computer Sciences


University of Lagos

•Lectures:
– E 304, Wednesday 10:00 am to 11:00 am
– Lab 203, Thursday 10:00 am to 12:00 am
Course Outline
We study topics in such areas as:
Sets and logic

proof techniques

relations and functions,

counting and combinatorics,

discrete probability,

graphs and trees and

NP-Completeness.
Course Material
Textbook

Discrete Mathematics
and Its Applications
by Kenneth H. Rosen

Use lecture notes as study guide.


Counting
and
Combinatorics
Presentation Outlines
Introduction

Basic Counting Principles


Sum Principle

Product Principle

Inclusion-Exclusion

Pigeonhole Principle

permutations

combinations
Pascal’s Triangle

Binomial coefficients
Introduction
Counting = Determining the number of elements of a finite set

Counting seems easy enough: 1, 2, 3, 4, etc.

This direct approach works well or counting simple things—like your

toes—and may be the only approach for extremely complicated things with

no identifiable structure.
Introduction
Discreet (simple, developed, advanced) methods can help in
solving Counting problems such as:
“How many different 8-letter passwords are there?”
“How many possible ways are there to pick 11 soccer players out of a 20-
player team?”
“How many different orders may 9 people be arranged in a line?“
“How many different ways can we chose from 4 colors and paint 6
rooms?“
Most importantly, counting is the basis for computing probabilities of
discrete events.
•(“What is the probability of winning the lottery?”)
Counting
Counting are important techniques in computer science,
especially in the analysis of algorithm.
Sorting and searching
combinatorial algorithms

Counting is useful in computer science for several reasons:


Determining the time and storage required to solve a computational
problem—a central objective in computer science—often comes down to
solving a counting problem.

Counting is the basis of probability theory, which plays a central role


in all sciences, including computer science.

Two remarkable proof techniques, the “pigeonhole principle” and


“combinatorial proof,” rely on counting. These lead to a variety of
interesting and useful insights.
Basic Counting Principle
There are lot of rules for counting.
These rules are actually theorems, and we will prove some of them, but
our focus won’t be on the proofs per se
We in Computer Science often need to count things, our objective is
to teach you simple counting as a practical skill, like integration.

•Sum Principle

•Product Principle

•Pigeonhole Principle
The sum rule:
If a first task can be done in n1 ways and a second task in n2 ways, and if
these tasks cannot be done at the same time. then there are n1+n2 ways
to do either task.

n1 n2

n1 + n2 ways

Example1:
 The department will award a free computer to either a CS student or a
CS professor. How many different choices are there, if there are 530
students and 15 professors?
Solution:
 There are 530 + 15 = 545 choices.
Example2:
 You have five novels, four magazines, and three devotional books. How many
options do you have for taking one for your wait in the bank line?

Solution:
 You have 3 subtasks - pick a novel, pick a magazine, or pick a devotional book.
The first can be done 5 ways, the second, 4 ways, and the third 3 ways.
Thus: 5 + 4 + 3 = 12 ways to perform.

Example3:
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:
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.
Example4
A student can choose a computer project from one of three lists. The
three lists contain 23, 15 and 19 possible projects respectively. How many
possible projects are there to choose from?

Solution:
23+15+19=57 projects

Exercise
–Suppose either a CS faculty or a CS student must be chosen for a
committee, and there are 4 CS faculty and 16 CS students. How many
possible choices are there?

–Suppose a student can meet the humanities course requirement by taking


either a religion, literature, or art course. There are 3 religion, 4
literature, or 4 art courses to chose from. How many possible choices are
there?
Generalized sum rule:
 If we have tasks T1, T2, …, Tm that can be done in n1, n2, …,
nm ways, respectively, and no two of these tasks can be done
at the same time, then there are n1 + n2 + … + nm ways to do
one of these tasks.
The Product rule:
Suppose that a procedure can be broken down into two tasks. If there are
n1 ways to do the first task and n2 ways to do the second task after the
first task has been done, then there are n1 . n2 ways to do the procedure

n1
n1 × n 2
ways
n2

Example1:
 How many different license plates are there that containing exactly
three English letters?

Solution:
 There are 26 possibilities to pick the first letter, then 26 possibilities
for the second one, and 26 for the last one.
So there are 262626 = 17576 different license plates.
Example2
How many different ways can we chose from 4 colors and paint 3 rooms?
Solution:
 Tasks:
• 1 - paint room 1 - 4 ways to perform (4 colors)
• 2 - paint room 2 - 4 ways to perform (4 colors)
• 3 - paint room 3 - 4 ways to perform (4 colors)
 Thus t1 = 4, t2 = 4, t3 = 4, and 4 . 4 . 4 = 64 ways to paint the rooms

Example3
How many different ways can we chose from 4 colors and paint 3 rooms, if
no room is to be the same color?
Solution:
 tasks:
• 1 - paint room 1 - 4 ways to perform (4 colors)
• 2 - paint room 2 - 3 ways to perform (3 colors left)
• 3 - paint room 3 - 2 ways to perform (2 colors left)
 Thus t1 = 4, t2 = 3, t3 = 2, and 4 . 3 . 2 = 24 ways to paint the rooms
Example4
How many different orders may 9 people be arranged in?

Solution:
 There are nine tasks - picking the first person, picking the second, …
 The first task has 9 choices, the second 8, ... and finally the ninth task
has 1 choice: 9 . 8 . 7 . 6 . 5 . 4 . 3 . 2 . 1 = 362880

Example5
The chair of an auditorium is 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?

Solution:
26 × 100 = 2600 ways to label chairs.
letter 1  x  100
x Ν
Exercise

1. How many different 3 people can be selected from a group of 8 people


to a president, vice-president, treasure of the group?

2. If student ID’s are two capital letters followed by three numeric


digits, then how many ID’s are possible?
What if the two letters must be distinct?

What if the letters and the numbers must all be distinct?

3. How many functions are there from a set with m elements to one with n
elements?

4. How many one-to-one functions are there from a set with m elements
to one with n element? Hints: (m  n)
Generalized product rule:
The product rule:
Suppose that a procedure can be broken down into two successive
tasks. If there are n1 ways to do the first task and n2 ways to do the
second task after the first task has been done, then there are n 1n2
ways to do the procedure.

Generalized product rule:


If we have a procedure consisting of sequential tasks T1, T2, …, Tm
that can be done in n1, n2, …, nm ways, respectively, then there are n1
 n2  …  nm ways to carry out the procedure.
Rule of sum and product
A class has 55 boys and 56 girls. What is the total number of
students in the class, and how many different possible boy girl
pairs are there?

Two disjoint sets, boys and girls,

•rule of sum implies 55+56=111 students.

•rule of product says 55.56 = 3080.


Inclusion-Exclusion
The subtraction rule, or the principle of inclusion–exclusion, can be
generalized to find the number of ways to do one of n different tasks or,
equivalently, to find the number of elements in the union of n sets,
whenever n is a positive integer.

For 3 sets
A ∪ B ∪ C| = |A| + |B| + |C| − |A ∩ B| − |A ∩ C| − |B ∩ C| + |A ∩ B ∩ C|

Example
A total of 1232 students have taken a course in Spanish, 879 have taken
a course in French, and 114 have taken a course in Russian. Further, 103
have taken courses in both Spanish and French, 23 have taken courses in
both Spanish and Russian, and 14 have taken courses in both French and
Russian. If 2092 students have taken at least one of Spanish, French, and
Russian, how many students have taken a course in all three languages?
Solution:
|S ∩ F ∩ R| = 7
The Pigeonhole Principle
If k + 1 or more objects are placed in k boxes, then there
is at least one box containing two or more objects.
The Pigeonhole Principle
If k + 1 or more objects are placed in k boxes, then there
is at least one box containing two or more objects.
The Pigeonhole Principle
If k + 1 or more objects are placed in k boxes, then there
is at least one box containing two or more objects.
The Pigeonhole Principle
If k + 1 or more objects are placed in k boxes, then there
is at least one box containing two or more objects.
Proof: Suppose that none of the k boxes contains more
then one object. Then the maximum number of objects
would be k. This is a contradiction, since there is at least k
+ 1 objects.
The Pigeonhole Principle
If there are 11 players in a soccer team that wins 12-0, there must
be at least one player in the team who scored at least twice.
If you have 6 classes from Monday to Friday, there must be at
least one day on which you have at least two classes.
Among 367 people, there must be at least 2 with the same
birthday, since there is only 366 possible birthdays.
In a collection of 10 numbers, at least 2 must have the same most
significant digit.

In a collection of 11 numbers, at least 2 must have the same least

significant digit.
The Pigeonhole Principle
How many people must we have in the same room to be
sure that at least two have the same birthday?
Are there two people in Computer Sciences dept. with the
same number of hairs?
Are there two people at Computer Sciences dept. the
same birthday?
Are there two people at Computer Sciences dept. with
birthdays on July 14?
The Pigeonhole Principle

 The Generalized Pigeonhole Principle:

If N objects are placed into k boxes, then there


is at least one box containing at least N/k
objects.
Generalized Pigeonhole Principle
 If N objects are placed into k boxes, then there is at
least one box containing at least N/k objects.
Generalized Pigeonhole Principle
 If N objects are placed into k boxes, then there is at
least one box containing at least N/k objects.
Generalized Pigeonhole Principle
 If N objects are placed into k boxes, then there is at
least one box containing at least N/k objects.
Generalized Pigeonhole Principle
 Proof: Suppose that none of the boxes contains more than
N/k - 1 objects. Then the total number of objects is at
most:
k (N/k - 1).
But since N/k < (N/k + 1), we get the following:
k (N/k - 1) < k (((N/k + 1) - 1) = N, thus
k (N/k - 1) < N
which is a contradiction since there is a total of N
objects.
Generalized Pigeonhole Principle
If N objects are placed into k boxes, then there is at least
one box containing at least N/k of the objects.

Example
In our 60-student class, at least 12 students will get the same letter
grade (A, B, C, D, or F).
Assume you have a drawer containing a random distribution of a dozen
brown socks and a dozen black socks. It is dark, so how many socks do you
have to pick to be sure that among them there is a matching pair?

There are two types of socks, so if you pick at least 3 socks, there must be
either at least two brown socks or at least two black socks.

Generalized pigeonhole principle: 3/2 = 2.

Among 100 people there are at least 100/12 = 9 people with the same
birthday month.
Exercise
1. Let n be a positive integer. Show that in any set of n consecutive
integers there is exactly one divisible by n.

2. A computer network consists of 6 computers. Each computer is


directly connected with zero or more of the other computers.
Show that there is at least two computers with the same
numbers of connections.

3. Show that if seven integers are selected from the first eight
positive integers, there must be pair of these integers with a
sum equal to to 9.
Is this still true if four integers are chosen instead of five?
Basic Counting Principles
The sum and product rules can also be phrased in
terms of set theory.
Sum rule:
Let A1, A2, …, Am be disjoint sets.
Then the number of ways to choose any element from one of
these sets is |A1  A2  …  Am | = |A1| + |A2| + … + |Am|.

Product rule:
Let A1, A2, …, Am be finite sets. Then the number of ways to
choose one element from each set in the order A1, A2, …, Am
is |A1  A2  …  Am | = |A1|  |A2|  …  |Am|.
Permutations
To find the number of Permutations of n items, we can use the
Fundamental Counting Principle or factorial notation.
Definition

n factorial is defined by (a) 0!=1; n!=n(n-1)(n-2)…(2)(1)


Note 0!=1

Definition
Given a collection of n distinct objects, any (linear) arrangement of
these objects is called a permutation of the collection
The number of permutations of size r from a collection of n distinct
objects is P(n, r)=n!/(n-r)!.
Calculating factorial and division
8! 8  7  6!
  8  7  56
6! 6!
We can divide above and below by 6!, which simplifies the calculation.

Example
Suppose that a saleswoman has to visit 8 different cities. She must begin
her trip in a specified city, but she can visit the other cities in any order
she wishes. How many possible orders can the saleswoman use when visiting
these cities ?

Solution
7! 5040
A permutation of a set of distinct objects is an ordered
arrangement of these objects in a particular order. An ordered
arrangement of r elements of a set is called an r-permutation, i.e. r
objects chosen from n objects.

Pr , means the number of ordered arrangements of r objects


n

chosen from n distinct objects and repetition is not allowed.


n!
n
Pr 
n  r!
Notice, ORDER MATTERS!
To find the number of Permutations of n items chosen r at a
time, you can use the formula

n!
p 
n r ( n  r )! where 0  r  n .

5! 5!
5 p3    5 * 4 * 3  60
(5  3)! 2!

4! 4  3  2 1
4
P4    24
 4  4 ! 0!

0! = 1
Example1
If you have 10 people racing and only 1st, 2nd and 3rd place
how many possible outcomes are there?

10! 10  9  8  7!
10
P3    720
10  3 ! 7!
Example2
A combination lock will open when the right choice of three
numbers (from 1 to 30, inclusive) is selected. How many different
lock combinations are possible assuming no number is repeated?

30! 30!
30 p3    30 * 29 * 28  24360
( 30  3)! 27!
Example3
From a club of 24 members, a President, Vice President,
Secretary, Treasurer and Historian are to be elected. In how
many ways can the offices be filled?

24! 24!
24 p5   
( 24  5)! 19!
24 * 23 * 22 * 21 * 20  5,100,480

You might also like