SlideShare a Scribd company logo
BITS Pilani, Hyderabad Campus
Session -6
Topic -1 : Combinatorics
Combinatorics is the study of finite or countable discrete
structures and
includes counting the structures of a given kind and size,
deciding when certain criteria can be met, and constructing
and
analyzing objects meeting the criteria, finding "largest",
"smallest", or "optimal" objects, and studying combinatorial
structures arising in an algebraic context, or applying
algebraic techniques to combinatorial problems.
Basic Counting Principles
• Sum Rule
• Product Rule
• THE 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.
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?
4
Binomial Coefficients
• (a + b)4 = (a + b)(a + b)(a + b)(a + b)
= a4

4
0





 + a3b

4
1





 + a2b2

4
2





 + ab3

4
3





 + b4

4
4






Binomial Theorem: Let x and y be variables, and let n be any
nonnegative integer. Then
(x  y)n

n
j






j 0
n
 xn j
y j

(x  y)n

n
j






j 0
n
 xn j
y j
• What is the coefficient of a8b9 in
the expansion of (3a +2b)17?
What is n? 17
What is j? 9
What is x? 3a
What is y? 2b

17
9






(3a)8
(2b)9

17
9






38
29
a8
b9
Binomial Coefficients
• (a + b)2 = a2 + 2ab + b2
• (a + b)3 = a3 + 3a2b + 3ab2 + b3
• (a + b)4 = a4 + 4a3b + 6a2b2 + 4ab3 + b4
What is coefficient
of a9b3 in (a + b)12?
A. 36
B. 220
C. 15
D. 6
E. No clue
Pascal’s triangle
A.: 220
j
j
n
n
0
j
n
y
x
j
n
y
x 

 








 )
(
Binomial Coefficients
• Sum each row of Pascal’s Triangle:
Powers of 2

n
j






j 0
n
  2n Suppose you have a set of size
n. How many subsets does
it have?
2n
How many subsets of size 0
does it have? nC0
How many subsets of size 1
does it have? nC1
How many subsets of size 2
does it have? nC2
Add them up we have the result.
j
j
n
n
0
j
n
y
x
j
n
y
x 

 








 )
(

n
j






j 0
n
  2n
Pick x=1 and y=1 !

n
j






j 0
n
 1n j
1j
 (1 1)n

n
j






j 0
n
  2n
• Alternative (clever) proof? Look at binomial
theorem…
x and y are variables; can pick
any numbers… hmm…
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 · 24 = 768 ports.
BITS Pilani, Hyderabad Campus
Session -6
Topic -1 : Combinatorics
The study of the number of ways to put things together into
various combinations.
E.g. If a password is 6-8 letters and/or digits, how many
passwords can there be?
Combinatorics is the study of finite or countable discrete structures
and includes counting the structures of a given kind and size,
deciding when certain criteria can be met, and constructing and
analyzing objects meeting the criteria, finding "largest", "smallest",
or "optimal" objects, and studying combinatorial structures arising
in an algebraic context, or applying algebraic techniques to
combinatorial problems.
BITS Pilani, Hyderabad Campus
Session -6
Topic -1 : Combinatorics
The study of the number of ways to put things together into
various combinations.
E.g. If a password is 6-8 letters and/or digits, how many
passwords can there be?
Combinatorics is the study of finite or countable discrete structures
and includes counting the structures of a given kind and size,
deciding when certain criteria can be met, and constructing and
analyzing objects meeting the criteria, finding "largest", "smallest",
or "optimal" objects, and studying combinatorial structures arising
in an algebraic context, or applying algebraic techniques to
combinatorial problems.
BITS Pilani, Hyderabad Campus
Sum and Product Rules
Let
m be the number of ways to do task 1 and
n the number of ways to do task 2,
with each number independent of how the other task is
done,
and also assume that no way to do task 1
simultaneously also accomplishes task 2.
Then, we have the following rules:
The sum rule: The task “do either task 1 or task 2,
but not both” can be done in m+n ways.
The product rule: The task “do both task 1 and task 2”
can be done in mn ways.
BITS Pilani, Hyderabad Campus
Set Theoretic Version
If
A is the set of ways to do task 1, and B the set of ways
to do task 2, and if A and B are disjoint, then:
The ways to do either task 1 or 2 are A U B, and
|AUB|=|A|+|B|
The ways to do both task 1 and 2 can be represented
as AXB, and |AXB|=|A|·|B|
BITS Pilani, Hyderabad Campus
IPAddress Example
The Internet Protocol, version 4 (IPv4)
– Valid computer addresses are in one of 3 types:
A class A IP address contains a 7-bit “netid” ≠ 17, and a
24-bit “hostid”
A class B address has a 14-bit netid and a 16-bit hostid.
A class C addr. Has 21-bit netid and an 8-bit hostid.
–The 3 classes have distinct headers (0, 10, 110)
–Hostids that are all 0s or all 1s are not allowed.
How many valid computer addresses are there?
e.g., xxx.edu is 128.227.74.58
BITS Pilani, Hyderabad Campus
IP address solution
(# addrs)
= (# class A) + (# class B) + (# class C)
(by sum rule)
# class A = (# valid netids)·(# valid hostids) (by
product rule)
(# valid class A netids) = 27 − 1 = 127.
(# valid class A hostids) = 224 − 2 =
16,777,214. Continuing in this fashion we find
the answer is: 3,737,091,842 (3.7 billion IP
addresses)
BITS Pilani, Hyderabad Campus
Inclusion-Exclusion Principle
• Let
• m be the number of ways to do task 1 and
• n be the number of ways to do task 2,
• Suppose that k<m of the ways of doing task 1 also
simultaneously accomplish task 2.
• – And thus are also ways of doing 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
|AUB|=|A|+|B|-|A∩B|.
• – If they are disjoint this simplifies to |A|+|B|.
BITS Pilani, Hyderabad Campus
Inclusion/Exclusion Example
Some hypothetical rules for passwords: Passwords must be
2 characters long. Each character must be
– a letter a-z (#=26),
– a digit 0-9 (#=10), or
– one of the punctuation characters (#=10)
!@#$%^&*().
Each password must contain at least 1 digit or punctuation
character.
BITS Pilani, Hyderabad Campus
Setup of Problem
A legal password has a digit or punctuation character
in position 1 or position 2.
These cases overlap, so the principle applies. (# of
passwords w. OK symbol in
position #1) = (10+10)·(10+10+26)
(# w. OK sym. in pos. #2): also 20·46 (# w. OK sym
both places): 20·20 Answer: 920+920−400 = 1,440
How many strings of eight English letters are there
a) that contain no vowels, if letters can be repeated?
b) that contain no vowels, if letters cannot be repeated?
c) that start with a vowel, if letters can be repeated?
d) that start with a vowel, if letters cannot be repeated?
e) that contain at least one vowel, if letters can be
repeated?
f ) that contain exactly one vowel, if letters can be
repeated?
g) that start with X and contain at least one vowel, if letters
can be repeated?
h) that start and end with X and contain at least one vowel,
if letters can be repeated?
COMBINATORICS.ppt
The name of a variable in the JAVA programming language is a string of
between 1 and 65,535 characters, inclusive, where each character can be an
uppercase or a lowercase letter, a dollar sign, an underscore, or a digit,
except that the first character must not be a digit. Determine the number of
different variable names in JAVA.
The name of a variable in the JAVA programming language is a string of
between 1 and 65,535 characters, inclusive, where each character can be an
uppercase or a lowercase letter, a dollar sign, an underscore, or a digit,
except that the first character must not be a digit. Determine the number of
different variable names in JAVA.

More Related Content

PPT
Combinatorics.ppt
PPT
Combinatorics
PPTX
Combinatorics PPT | Discrete Mathematics.pptx
PDF
Discrete-Chapter 06 Counting
PPTX
counting techniques
DOC
Technical aptitude questions_e_book1
PDF
Unit III - 1 Discrerte maths and its applciation
PPT
Algorithms
Combinatorics.ppt
Combinatorics
Combinatorics PPT | Discrete Mathematics.pptx
Discrete-Chapter 06 Counting
counting techniques
Technical aptitude questions_e_book1
Unit III - 1 Discrerte maths and its applciation
Algorithms

Similar to COMBINATORICS.ppt (20)

PDF
Digital Systems Design Using Verilog 1st edition by Roth John Lee solution ma...
PPTX
Number systems and Digital code_VSG
DOC
Data structure-questions
PPTX
Algorithms Exam Help
PDF
Sienna 1 intro
PPT
Basic counting in DSA for IT or Computer Science students
DOC
Exercises for pupils in primary education(0 4)-en
PPTX
Digital electronics unit 1 boolean algebra
PDF
ilp-nlp-slides.pdf
PPTX
Constraint Satisfaction Problems - Copy.pptx
PDF
‘How to develop Pythonic coding rather than Python coding – Logic Perspective’
DOCX
AD3351 DAA ANSWER KEY question and answer .docx
PPT
discrete mathematics counting for bachelor in information technology and comp...
PPTX
Factors and Multiples for - grade 6 level
PDF
Q33_LE_Mathematics 8_Lesson 7_Week 7.pdf
PDF
Combinatorial Problems2
PPT
tutorial5.ppt
PDF
Programming for Data Analysis: Week 4
PPTX
Bit-Manipulation for competitive programming
PPTX
Algorithm & data structures lec1
Digital Systems Design Using Verilog 1st edition by Roth John Lee solution ma...
Number systems and Digital code_VSG
Data structure-questions
Algorithms Exam Help
Sienna 1 intro
Basic counting in DSA for IT or Computer Science students
Exercises for pupils in primary education(0 4)-en
Digital electronics unit 1 boolean algebra
ilp-nlp-slides.pdf
Constraint Satisfaction Problems - Copy.pptx
‘How to develop Pythonic coding rather than Python coding – Logic Perspective’
AD3351 DAA ANSWER KEY question and answer .docx
discrete mathematics counting for bachelor in information technology and comp...
Factors and Multiples for - grade 6 level
Q33_LE_Mathematics 8_Lesson 7_Week 7.pdf
Combinatorial Problems2
tutorial5.ppt
Programming for Data Analysis: Week 4
Bit-Manipulation for competitive programming
Algorithm & data structures lec1
Ad

Recently uploaded (20)

PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
Lesson notes of climatology university.
PPTX
Pharma ospi slides which help in ospi learning
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PPTX
master seminar digital applications in india
PDF
RMMM.pdf make it easy to upload and study
PDF
Classroom Observation Tools for Teachers
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
Presentation on HIE in infants and its manifestations
PPTX
Institutional Correction lecture only . . .
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
Module 4: Burden of Disease Tutorial Slides S2 2025
Lesson notes of climatology university.
Pharma ospi slides which help in ospi learning
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
master seminar digital applications in india
RMMM.pdf make it easy to upload and study
Classroom Observation Tools for Teachers
Pharmacology of Heart Failure /Pharmacotherapy of CHF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
Anesthesia in Laparoscopic Surgery in India
Presentation on HIE in infants and its manifestations
Institutional Correction lecture only . . .
O7-L3 Supply Chain Operations - ICLT Program
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
human mycosis Human fungal infections are called human mycosis..pptx
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Ad

COMBINATORICS.ppt

  • 1. BITS Pilani, Hyderabad Campus Session -6 Topic -1 : Combinatorics Combinatorics is the study of finite or countable discrete structures and includes counting the structures of a given kind and size, deciding when certain criteria can be met, and constructing and analyzing objects meeting the criteria, finding "largest", "smallest", or "optimal" objects, and studying combinatorial structures arising in an algebraic context, or applying algebraic techniques to combinatorial problems.
  • 2. Basic Counting Principles • Sum Rule • Product Rule • THE 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.
  • 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?
  • 4. 4 Binomial Coefficients • (a + b)4 = (a + b)(a + b)(a + b)(a + b) = a4  4 0       + a3b  4 1       + a2b2  4 2       + ab3  4 3       + b4  4 4       Binomial Theorem: Let x and y be variables, and let n be any nonnegative integer. Then (x  y)n  n j       j 0 n  xn j y j
  • 5.  (x  y)n  n j       j 0 n  xn j y j • What is the coefficient of a8b9 in the expansion of (3a +2b)17? What is n? 17 What is j? 9 What is x? 3a What is y? 2b  17 9       (3a)8 (2b)9  17 9       38 29 a8 b9
  • 6. Binomial Coefficients • (a + b)2 = a2 + 2ab + b2 • (a + b)3 = a3 + 3a2b + 3ab2 + b3 • (a + b)4 = a4 + 4a3b + 6a2b2 + 4ab3 + b4 What is coefficient of a9b3 in (a + b)12? A. 36 B. 220 C. 15 D. 6 E. No clue Pascal’s triangle A.: 220
  • 7. j j n n 0 j n y x j n y x              ) ( Binomial Coefficients • Sum each row of Pascal’s Triangle: Powers of 2  n j       j 0 n   2n Suppose you have a set of size n. How many subsets does it have? 2n How many subsets of size 0 does it have? nC0 How many subsets of size 1 does it have? nC1 How many subsets of size 2 does it have? nC2 Add them up we have the result.
  • 8. j j n n 0 j n y x j n y x              ) (  n j       j 0 n   2n Pick x=1 and y=1 !  n j       j 0 n  1n j 1j  (1 1)n  n j       j 0 n   2n • Alternative (clever) proof? Look at binomial theorem… x and y are variables; can pick any numbers… hmm…
  • 9. 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 · 24 = 768 ports.
  • 10. BITS Pilani, Hyderabad Campus Session -6 Topic -1 : Combinatorics The study of the number of ways to put things together into various combinations. E.g. If a password is 6-8 letters and/or digits, how many passwords can there be? Combinatorics is the study of finite or countable discrete structures and includes counting the structures of a given kind and size, deciding when certain criteria can be met, and constructing and analyzing objects meeting the criteria, finding "largest", "smallest", or "optimal" objects, and studying combinatorial structures arising in an algebraic context, or applying algebraic techniques to combinatorial problems.
  • 11. BITS Pilani, Hyderabad Campus Session -6 Topic -1 : Combinatorics The study of the number of ways to put things together into various combinations. E.g. If a password is 6-8 letters and/or digits, how many passwords can there be? Combinatorics is the study of finite or countable discrete structures and includes counting the structures of a given kind and size, deciding when certain criteria can be met, and constructing and analyzing objects meeting the criteria, finding "largest", "smallest", or "optimal" objects, and studying combinatorial structures arising in an algebraic context, or applying algebraic techniques to combinatorial problems.
  • 12. BITS Pilani, Hyderabad Campus Sum and Product Rules Let m be the number of ways to do task 1 and n the number of ways to do task 2, with each number independent of how the other task is done, and also assume that no way to do task 1 simultaneously also accomplishes task 2. Then, we have the following rules: The sum rule: The task “do either task 1 or task 2, but not both” can be done in m+n ways. The product rule: The task “do both task 1 and task 2” can be done in mn ways.
  • 13. BITS Pilani, Hyderabad Campus Set Theoretic Version If A is the set of ways to do task 1, and B the set of ways to do task 2, and if A and B are disjoint, then: The ways to do either task 1 or 2 are A U B, and |AUB|=|A|+|B| The ways to do both task 1 and 2 can be represented as AXB, and |AXB|=|A|·|B|
  • 14. BITS Pilani, Hyderabad Campus IPAddress Example The Internet Protocol, version 4 (IPv4) – Valid computer addresses are in one of 3 types: A class A IP address contains a 7-bit “netid” ≠ 17, and a 24-bit “hostid” A class B address has a 14-bit netid and a 16-bit hostid. A class C addr. Has 21-bit netid and an 8-bit hostid. –The 3 classes have distinct headers (0, 10, 110) –Hostids that are all 0s or all 1s are not allowed. How many valid computer addresses are there? e.g., xxx.edu is 128.227.74.58
  • 15. BITS Pilani, Hyderabad Campus IP address solution (# addrs) = (# class A) + (# class B) + (# class C) (by sum rule) # class A = (# valid netids)·(# valid hostids) (by product rule) (# valid class A netids) = 27 − 1 = 127. (# valid class A hostids) = 224 − 2 = 16,777,214. Continuing in this fashion we find the answer is: 3,737,091,842 (3.7 billion IP addresses)
  • 16. BITS Pilani, Hyderabad Campus Inclusion-Exclusion Principle • Let • m be the number of ways to do task 1 and • n be the number of ways to do task 2, • Suppose that k<m of the ways of doing task 1 also simultaneously accomplish task 2. • – And thus are also ways of doing 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 |AUB|=|A|+|B|-|A∩B|. • – If they are disjoint this simplifies to |A|+|B|.
  • 17. BITS Pilani, Hyderabad Campus Inclusion/Exclusion Example Some hypothetical rules for passwords: Passwords must be 2 characters long. Each character must be – a letter a-z (#=26), – a digit 0-9 (#=10), or – one of the punctuation characters (#=10) !@#$%^&*(). Each password must contain at least 1 digit or punctuation character.
  • 18. BITS Pilani, Hyderabad Campus Setup of Problem A legal password has a digit or punctuation character in position 1 or position 2. These cases overlap, so the principle applies. (# of passwords w. OK symbol in position #1) = (10+10)·(10+10+26) (# w. OK sym. in pos. #2): also 20·46 (# w. OK sym both places): 20·20 Answer: 920+920−400 = 1,440
  • 19. How many strings of eight English letters are there a) that contain no vowels, if letters can be repeated? b) that contain no vowels, if letters cannot be repeated? c) that start with a vowel, if letters can be repeated? d) that start with a vowel, if letters cannot be repeated? e) that contain at least one vowel, if letters can be repeated? f ) that contain exactly one vowel, if letters can be repeated? g) that start with X and contain at least one vowel, if letters can be repeated? h) that start and end with X and contain at least one vowel, if letters can be repeated?
  • 21. The name of a variable in the JAVA programming language is a string of between 1 and 65,535 characters, inclusive, where each character can be an uppercase or a lowercase letter, a dollar sign, an underscore, or a digit, except that the first character must not be a digit. Determine the number of different variable names in JAVA.
  • 22. The name of a variable in the JAVA programming language is a string of between 1 and 65,535 characters, inclusive, where each character can be an uppercase or a lowercase letter, a dollar sign, an underscore, or a digit, except that the first character must not be a digit. Determine the number of different variable names in JAVA.