Unit-2 Lecture Notes - 24-25
Unit-2 Lecture Notes - 24-25
Question: Write down the well ordering principle. [Winter 2023 – 24]
RECURSION:
Sometimes it is difficult to define an object explicitly. However, it may be easy to define this object in termsof
itself. This process is called Recursion.
Recursive Step: Give a rule for finding its value at an integer from its values at smaller integers. Such adefinition
is called a recursive or inductive.
Example-1:
Suppose that f is defined recursively by
f (0) = 3,
f (n +1) = 2 f (n) + 3
Find f (1), f (2), f (3) & f (4). [Winter 2021 – 22]
Solution:
From the recursive definition it follows that
f (1) = 2 f (0) + 3 = 2*3 + 3 = 9
f (2) = 2 f (1) + 3 = 2*9 + 3 = 21
f (3) = 2 f (2) + 3 = 2* 21+ 3 = 45
f (4) = 2 f (3) + 3 = 2* 45 + 3 = 93
Example-2:
Give a recursive definition of a n , where a is a nonzero real number and n is a non-negativeinteger.
Solution:
The recursive definition contains two parts:
First a 0 is specified, namely, a0 = 1 . Then the rule for finding an+1 from a n , namely,
Let S(n) be any statement which is to be proved that it is true for all n∈ Z+, we must follow three steps forit.
Step 1: Prove for 𝑛 = 𝑛0 , the result is true where, 𝑛0 is initial value. this step is called basic/ initial step.Step
2: Assume for 𝑛 = 𝑘, the result S(k) is true.
Step 3: Prove for 𝑛 = 𝑘 + 1 the result is true.
This step is called inductive step. If all steps are valid, then S(n) is true in general, for n∈Z+.
Example-3:
Exercise-1
Using mathematical induction method, Prove the following:
𝑛(𝑛 + 1)
1. 1 + 2 + 3 +, . . . . . . + 𝑛 = [Winter 2022 - 23]
2
𝑛(2𝑛−1)(2𝑛+1)
2. 12 + 22 + 32 +, … . . , +(2𝑛 − 1) = 2
[Winter 2017 – 18]
3
(3𝑛 −1)
3. 1 + 3 + 32 + 33 + 34 +, … … … , + 3𝑛−1 = [Summer 2017 – 18]
2
Example-4:
What are the quotient and remainder when 101 is divided by 11?
Solution:
We have 101 =11* 9 + 2
Hence, the quotient when 101 is divided by 11 is 9 = 101 div 11, and the remainder is 2 =101 mod 11.
Example-5:
What are the quotient and remainder when - 11 is divided by 3?
Solution:
We have −11 = 3*(−4) +1
Hence, the quotient when - 11 is divided by 3 is -4 = -11 div 3, and the remainder is 1 = -11mod 3.
Note that the remainder cannot be negative. Consequently, the remainder is not -2, even though
−11 = 3 because r = -2 does not satisfy 0 r 3.
PRIMES:
A positive integer p greater than 1 is called prime if the only positive factors of p are 1 and p .
COMPOSITE:
A positive integer that is greater than 1 and is not prime is called composite.
Remark: The integer n is composite if and only if there exists an integer a such that a / n and 1 a n .
For example: The integer 7 is prime because its only positive factors are 1 and 7, whereas the integer 9 is
composite because it is divisible by 3.
Every positive integer greater than 1 can be written uniquely as a prime or as the product of two or more
primes where the prime factors are written in order of non-decreasing size.
Example-6:
The prime factorizations of 100, 641, 999, and 1024 are given by
Solution:
100 = 2 2 5 5 = 22 52
641 = 641
999 = 3 3 3 37 = 33 37
1024 = 210
Remark: If n is a composite integer, then n has a prime divisor less than or equal to .
Example-7:
Show that 101 is prime.
Solution: The only primes not exceeding 101 are 2, 3, 5, and 7. Because 101 is not divisible by 2, 3, 5, or 7
(the quotient of 101 and each of these integers is not an integer), it follows that 101 is prime.
Example-8:
What is the greatest common divisor of 24 and 36?
Solution:
The positive common divisors of 24 and 36 are 1, 2, 3, 4, 6, and 12. Hence, gcd(24, 36) = 12 .
Example-9:
What is the greatest common divisor of 17 and 22?
Solution:
The integers 1 7 and 22 have no positive common divisors other than 1. So that gcd( 17, 22) = 1 .
EUCLIDEAN ALGORITHM:
We will give a more efficient method of finding the greatest common divisor, called the Euclidean algorithm.
This algorithm has been known since ancient times.
Divide:
Start with two numbers, let a and b, where a is greater than or equal to b
Swap and Repeat: Replace a with b and b with r. This step essentially swaps the numbers and reduces the problem
size.
So, in essence, the Euclidean algorithm involves repeatedly replacing the larger number by its remainder when
divided by the smaller number, until one of the numbers becomes zero.
Example-10:
Find gcd (91,287) using Euclidean algorithm.
Solution:
First, divide 287, the larger of the two integers, by 91, the smaller, 287 = 91 x 3 + 14.
Any divisor of 91 and 287 must also be a divisor of 287 - 91 x 3 = 14.
Also, any divisor of 91 and 14 must also be a divisor of 287 = 91 x 3 + 14.
Hence, the greatest common divisor of 91 and 287 is the same as the greatest common divisor of 91 and 14.
This means that the problem of finding gcd (91, 287) has been reduced to the problem of finding gcd (91, 14).
Next, divide 91 by 14 to obtain 91 = 14 x 6 + 7.
Because any common divisor of 91 and 14 also divides 91 -14 x 6 = 7 and any common divisor of 14 and 7
divides 91.
Therefore gcd(91 ,14) = gcd( 14, 7). Continue by dividing 14 by 7, to obtain 14 = 7 x 2.
Because 7 divides 14, it follows that gcd(14, 7) = 7.
Furthermore, because gcd(287, 91 ) = gcd(91 , 14) = gcd( 14, 7) = 7.
.
Example-11:
Find the greatest common divisor of 414 and 662 using the Euclidean algorithm. [Winter 2022-23]
Solution:
Successive uses of the division algorithm give:662 = 414 x 1+248
414 = 248 x 1 + 166
248 = 166 x 1 + 82
166 = 82 x 2 + 2
82 = 2 x 41.
Hence, gcd(414, 662) = 2, because 2 is the last nonzero remainder.
Exercise-2:
1. Use Euclidean algorithm to find the HCF of 4052 and 12576. [Winter 2019 – 20]
2. Using Euclidean algorithm find g.c.d (735,85) [Winter 2023 – 24]
3. Using Euclidean algorithm find gcd(252,105) [Winter 2022 - 23]
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-12:
A new company with just two employees, Sanchez and Patel, rents a floor of a building with 12 offices.
How many ways are there to assign different offices to these two employees?
Solution:
The procedure of assigning offices to these two employees consists of assigning an office to Sanchez, which can
be done in 12 ways, then assigning an office to Patel different from the office assigned to Sanchez, which can be
done in 11 ways. By the product rule, there are 12 x 11 = 132 ways to assign offices to these two employees. ...
Example-13:
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?
Solution:
The procedure of labeling a chair consists of two tasks, namely, assigning one of the 26 letters andthen assigning
one of the 100 possible integers to the seat. The product rule shows that there are 26 x 100 = 2600 different ways
that a chair can be labeled. Therefore, the largest number of chairs thatcan be labeled differently is 2600.
Example-14:
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:
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 x 24 = 768 ports.
Example-15:
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.
Example-16:
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:
The student can choose a project by selecting a project from the first list, the second list, or the third list. Because
n project is on more than one list, by the sum rule there are 23 + 15 + 19 = 57 ways to choose a project.
INCLUSION-EXCLUSION PRINCIPLE:
To correctly count the number of ways to do the two tasks, we add the number of ways to do it in one wayand
the number of ways to do it in the other way, and then subtract the number of ways to do the task in a
way that is both among the set of n1 ways and the set of n2 ways. This technique is called the principle of
inclusion-exclusion. Sometimes, it is also called the subtraction principle of counting.
Example-17:
How many bit strings of length eight either start with a 1 bit or end with the two bits 00?
Solution:
We can construct a bit string of length eight that start with 1 in 27 =128
This follows by the product rule, because the first bit can be chosen in only one way and each of the other seven
bits can be chosen in two ways.
Next, we construct bit string of length eight that end with 00 in 26 =64 ways.
This follows by the product rule, because the first 6 bits can be chosen in two ways and the last two bits can be
chosen in only one way.
We construct a bit string of length eight that start with 1 and end with 00 in 1 and end with 00 in 25 =32 ways.
which equals the number of ways to construct a bit string of length eight that begin with a 1 or that ends with
00, equals 128 + 64 - 32 = 160 ways.
Example-18:
A computer company receives 350 applications from computer graduates for a job planning a line of new Web
servers. Suppose that 220 of these people majored in computer science, 147 majored in business, and 51 majored
both in computer science and in business. How many of these applicants majored neither in computer science nor
in business? [Winter 2019 – 20]
Solution:
To find the number of these applicants who majored neither in computer science nor in business, we can subtract
the number of students who majored either in computer science or in business (or both) from the total number
of applicants.
Let A1 be the set of students who majored in computer science and A2 the set of students who majored in
business.
Then A1 A2 is the set of students who majored in computer science or business (or both), and A1 A2 is
the set of students who majored both in computer science and in business. By the principle of inclusion-
exclusion, the number of students who majored either in computer science or in business (or both) equals
|𝐴1 ∪ 𝐴2| = |𝐴1| + |𝐴2| − |𝐴1 ∩ 𝐴2|= 220 + 147 - 51 = 316.
We conclude that 350 - 316 = 34 of the applicants majored neither in computer science nor in business
Remark: A function f from a set with k + 1 or more elements to a set with k elements is not one-to-one.
For example,
- Among any group of 367 people, there must be at least two with the same birthday, because thereare only
366 possible birthdays.
- In any group of 27 English words, there must be at least two that begin with the same letter, because
there are 26 letters in the English alphabet.
PERMUTATIONS:
A permutation of a set of distinct objects is an ordered arrangement of these objects. We also are interested in
ordered arrangements of some of the elements of a set. An ordered arrangement of r elements of a set is called an
r-permutation.
𝑛!
𝑃(𝑛, 𝑟) =
(𝑛 − 𝑟)!
COMBINATIONS:
A Combination of these n objects taken r at a time is any selection of r of the objects where order does not
count. In other words, r-combination of a set of n objects is any subset of r elements.
𝑛!
𝐶(𝑛, 𝑟) =
𝑟! (𝑛 − 𝑟)!
Remarks:
1. 𝑃(𝑛 , 𝑛) = 𝑛!
2. 0! = 1
3. 𝐶(𝑛, 𝑛) = 1
4. 𝐶(𝑛, 𝑟) = 𝐶(𝑛, 𝑛 − 𝑟)
5. If n and r are positive integers, where 𝑛 ≥ r, then C(n, r-1) + C(n, r) = C(n+1,r)
6. Circular Permutation: The number of different circular arrangements of n objects = (n-1) !
In general,
Product rule: If an activity can be performed in r-successive steps and step 1 can be done in n1 ways, step 2 can
be done in n2 ways,…. Step r can be done in nr ways then the activity can be done in (n1,n2,n3,….nr) ways.
Sum rule: If r activities can be performed in n1,n2,n3,….nr ways and if they are disjoint , i.e cannot be
performed simultaneously , then any one of the r-activities can be performed in (n1+n2 +n3+….+nr) ways.
Example-19:
How many bit strings of length n contain exactly r 1’s?
Solution:
The positions of r 1’s in a bit string of length n form an r-combination of the set { 1 , 2 , 3 , . . . , n}.
Hence, there are C (n, r) bit strings of length n that contain exactly r 1’s.
Example-20:
Suppose that there are 9 faculty members in the mathematics department and 11 in the computer science
department. How many ways are there to select a committee to develop a discrete mathematics course at a school
if the committee is to consist of three faculty members from the mathematics department and four from the
computer science department?
Solution:
By the product rule, the answer is the product of the number of 3-combinations of a set with nine elements and
the number of 4-combinations of a set with 11 elements. By Theorem the number of ways to select the committee
is
9! 11!
𝐶(9,3) ∗ 𝐶(11,4) = ∗ = 84 ∗ 330 = 27720
3! ∗ 6! 4! ∗ 7!
Example-21:
Suppose that a saleswoman has to visit eight different cities. She must begin her trip in a specified city, but she
can visit the other seven cities in any order she wishes. How many possible orders can the saleswoman use when
visiting these cities?
Solution:
The number of possible paths between the cities is the number of permutations of seven elements, because the
first city is determined, but the remaining seven can be ordered arbitrarily. Consequently, there are 7! = 7 · 6 · 5
· 4 · 3 · 2 · 1 = 5040 ways for the saleswoman to choose her tour. If, for instance, the saleswoman wishes to find
the path between the cities with minimum distance, and she computes the total distance for each possible path,
she must consider a total of 5040 paths.
Example-22:
How many ways are there to select a first-prize winner, a second-prize winner, and a third-prize winner from 100
different people who have entered a contest?
Solution:
Because it matters which person wins which prize, the number of ways to pick the three prize winners is the
number of ordered selections of three elements from a set of 100 elements, that is, the number of 3-permutations
of a set of 100 elements. Consequently, the answer is P ( l00, 3) = 100 ·99 · 98 = 970,200.
Example-23:
A group of 30 people have been trained as astronauts to go on the first mission to Mars. How many ways are there
to select a crew of six people to go on this mission (assuming that all crew members have the same job)?
Solution:
The number of ways to select a crew of six from the pool of 30 people is the number of 6-combinations of a set
with 30 elements, because the order in which these people are chosen does not matter. By Theorem 2, the
number of such combinations is C(30, 6) = 30! 6! 24! = 30 · 29 · 28 · 27 · 26 · 25 6 · 5 · 4 · 3 · 2 · 1 = 593,775.
Example-24:
Suppose that there are 9 faculty members in the mathematics department and 11 in the computer science
department. How many ways are there to select a committee to develop a discrete mathematics course at a school
if the committee is to consist of three faculty members from the mathematics department and four from the
computer science department? [Winter 2019 – 20]
Solution:
By the product rule, the answer is the product of the number of 3-combinations of a set with nine elements and the
number of 4-combinations of a set with 11 elements. By Theorem 2, the number of ways to select the committee
is C(9, 3) · C(11, 4) = 9! 3!6! · 11! 4!7! = 84 · 330 = 27,720.