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?
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-questions
Shekhar Chander
 
Algorithms Exam Help
Algorithms Exam HelpAlgorithms Exam Help
Algorithms Exam Help
Programming Exam Help
 
Sienna 1 intro
Sienna 1 introSienna 1 intro
Sienna 1 intro
chidabdu
 
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
Georgeta Manafu
 
ilp-nlp-slides.pdf
ilp-nlp-slides.pdfilp-nlp-slides.pdf
ilp-nlp-slides.pdf
FlorentBersani
 
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 Problems2
3ashmawy
 
tutorial5.ppt
tutorial5.ppttutorial5.ppt
tutorial5.ppt
jvjfvvoa
 
Programming for Data Analysis: Week 4
Programming for Data Analysis: Week 4Programming for Data Analysis: Week 4
Programming for Data Analysis: Week 4
Ferdin Joe John Joseph PhD
 
Algorithm & data structures lec1
Algorithm & data structures lec1Algorithm & data structures lec1
Algorithm & data structures lec1
Abdul Khan
 
Daa chapter4
Daa chapter4Daa chapter4
Daa chapter4
B.Kirron Reddi
 
Mit6 006 f11_quiz1
Mit6 006 f11_quiz1Mit6 006 f11_quiz1
Mit6 006 f11_quiz1
Sandeep Jindal
 
design and analysis of algorithm
design and analysis of algorithmdesign and analysis of algorithm
design and analysis of algorithm
Muhammad Arish
 
Chapter 4:Object-Oriented Basic Concepts
Chapter 4:Object-Oriented Basic ConceptsChapter 4:Object-Oriented Basic Concepts
Chapter 4:Object-Oriented Basic Concepts
It 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 Integers
wzuri
 
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
Homer53
 
Constraint Satisfaction.pdf
Constraint Satisfaction.pdfConstraint Satisfaction.pdf
Constraint Satisfaction.pdf
HarshitaSharma285596
 
Foundation_Logic_1.pptx discrete mathematics
Foundation_Logic_1.pptx discrete mathematicsFoundation_Logic_1.pptx discrete mathematics
Foundation_Logic_1.pptx discrete mathematics
SherwinSangalang3
 

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

How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
Celine George
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
amberjdewit93
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
simonomuemu
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
RAHUL
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
RitikBhardwaj56
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
Dr. Mulla Adam Ali
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 

Recently uploaded (20)

How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 

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.