SlideShare a Scribd company logo
1 of 22
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?
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

Similar to COMBINATORICS.ppt

Data structure-questions
Data structure-questionsData structure-questions
Data structure-questionsShekhar Chander
 
Sienna 1 intro
Sienna 1 introSienna 1 intro
Sienna 1 introchidabdu
 
Exercises for pupils in primary education(0 4)-en
Exercises for pupils in primary education(0 4)-enExercises for pupils in primary education(0 4)-en
Exercises for pupils in primary education(0 4)-enGeorgeta Manafu
 
discrete mathematics counting for bachelor in information technology and comp...
discrete mathematics counting for bachelor in information technology and comp...discrete mathematics counting for bachelor in information technology and comp...
discrete mathematics counting for bachelor in information technology and comp...MUSASIZIRONALD
 
Combinatorial Problems2
Combinatorial Problems2Combinatorial Problems2
Combinatorial Problems23ashmawy
 
tutorial5.ppt
tutorial5.ppttutorial5.ppt
tutorial5.pptjvjfvvoa
 
Algorithm & data structures lec1
Algorithm & data structures lec1Algorithm & data structures lec1
Algorithm & data structures lec1Abdul Khan
 
design and analysis of algorithm
design and analysis of algorithmdesign and analysis of algorithm
design and analysis of algorithmMuhammad Arish
 
Chapter 4:Object-Oriented Basic Concepts
Chapter 4:Object-Oriented Basic ConceptsChapter 4:Object-Oriented Basic Concepts
Chapter 4:Object-Oriented Basic ConceptsIt Academy
 
Engineering Fast Indexes for Big-Data Applications: Spark Summit East talk by...
Engineering Fast Indexes for Big-Data Applications: Spark Summit East talk by...Engineering Fast Indexes for Big-Data Applications: Spark Summit East talk by...
Engineering Fast Indexes for Big-Data Applications: Spark Summit East talk by...Spark Summit
 
Engineering fast indexes (Deepdive)
Engineering fast indexes (Deepdive)Engineering fast indexes (Deepdive)
Engineering fast indexes (Deepdive)Daniel Lemire
 
(7) Lesson 3.2 - Add Integers
(7) Lesson 3.2 - Add Integers(7) Lesson 3.2 - Add Integers
(7) Lesson 3.2 - Add Integerswzuri
 
Lecture_15_Chapter_5_Lesson_5.1 (1).pptx
Lecture_15_Chapter_5_Lesson_5.1 (1).pptxLecture_15_Chapter_5_Lesson_5.1 (1).pptx
Lecture_15_Chapter_5_Lesson_5.1 (1).pptxHomer53
 
Foundation_Logic_1.pptx discrete mathematics
Foundation_Logic_1.pptx discrete mathematicsFoundation_Logic_1.pptx discrete mathematics
Foundation_Logic_1.pptx discrete mathematicsSherwinSangalang3
 

Similar to COMBINATORICS.ppt (20)

Data structure-questions
Data structure-questionsData structure-questions
Data structure-questions
 
Algorithms Exam Help
Algorithms Exam HelpAlgorithms Exam Help
Algorithms Exam Help
 
Sienna 1 intro
Sienna 1 introSienna 1 intro
Sienna 1 intro
 
Exercises for pupils in primary education(0 4)-en
Exercises for pupils in primary education(0 4)-enExercises for pupils in primary education(0 4)-en
Exercises for pupils in primary education(0 4)-en
 
ilp-nlp-slides.pdf
ilp-nlp-slides.pdfilp-nlp-slides.pdf
ilp-nlp-slides.pdf
 
discrete mathematics counting for bachelor in information technology and comp...
discrete mathematics counting for bachelor in information technology and comp...discrete mathematics counting for bachelor in information technology and comp...
discrete mathematics counting for bachelor in information technology and comp...
 
Combinatorial Problems2
Combinatorial Problems2Combinatorial Problems2
Combinatorial Problems2
 
tutorial5.ppt
tutorial5.ppttutorial5.ppt
tutorial5.ppt
 
Programming for Data Analysis: Week 4
Programming for Data Analysis: Week 4Programming for Data Analysis: Week 4
Programming for Data Analysis: Week 4
 
Algorithm & data structures lec1
Algorithm & data structures lec1Algorithm & data structures lec1
Algorithm & data structures lec1
 
Daa chapter4
Daa chapter4Daa chapter4
Daa chapter4
 
Mit6 006 f11_quiz1
Mit6 006 f11_quiz1Mit6 006 f11_quiz1
Mit6 006 f11_quiz1
 
design and analysis of algorithm
design and analysis of algorithmdesign and analysis of algorithm
design and analysis of algorithm
 
Chapter 4:Object-Oriented Basic Concepts
Chapter 4:Object-Oriented Basic ConceptsChapter 4:Object-Oriented Basic Concepts
Chapter 4:Object-Oriented Basic Concepts
 
Engineering Fast Indexes for Big-Data Applications: Spark Summit East talk by...
Engineering Fast Indexes for Big-Data Applications: Spark Summit East talk by...Engineering Fast Indexes for Big-Data Applications: Spark Summit East talk by...
Engineering Fast Indexes for Big-Data Applications: Spark Summit East talk by...
 
Engineering fast indexes (Deepdive)
Engineering fast indexes (Deepdive)Engineering fast indexes (Deepdive)
Engineering fast indexes (Deepdive)
 
(7) Lesson 3.2 - Add Integers
(7) Lesson 3.2 - Add Integers(7) Lesson 3.2 - Add Integers
(7) Lesson 3.2 - Add Integers
 
Lecture_15_Chapter_5_Lesson_5.1 (1).pptx
Lecture_15_Chapter_5_Lesson_5.1 (1).pptxLecture_15_Chapter_5_Lesson_5.1 (1).pptx
Lecture_15_Chapter_5_Lesson_5.1 (1).pptx
 
Constraint Satisfaction.pdf
Constraint Satisfaction.pdfConstraint Satisfaction.pdf
Constraint Satisfaction.pdf
 
Foundation_Logic_1.pptx discrete mathematics
Foundation_Logic_1.pptx discrete mathematicsFoundation_Logic_1.pptx discrete mathematics
Foundation_Logic_1.pptx discrete mathematics
 

Recently uploaded

Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 

Recently uploaded (20)

Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 

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?
  • 20.
  • 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.