SlideShare a Scribd company logo
1 of 16
Download to read offline
Computer Science Division: CS301 
Course CS301, Part: 
“ALGORITHMIC COMBINATORICS I” 
( 3rd Year Students ) 
Prepared by: 
http://www.researchgate.net/profile/Ahmed_Abdel-Fattah 
Lecture #3 
N.B. The Mid-Term Exam will be held on 08-NOV-2014 
(and it includes this lecture) 
Dr. Ahmed Ashry “Algorithmic Combinatorics I” for 3rd Year Students — Lecture #3 1 (of 16)
Computer Science Division: CS301 
Selections with REPETITIONS: 
When an object can be chosen more than once. 
Example: Unordered Pairs of Numbers 
A domino is a rectangular piece whose top face is divided into 2 squares. 
Each of the squares contains between 0 (blank) and 6 dots. 
How many different domino faces are possible? 
Dr. Ahmed Ashry “Algorithmic Combinatorics I” for 3rd Year Students — Lecture #3 2 (of 16)
Computer Science Division: CS301 
Theorem (Selections with Unlimited Repetitions:a) 
a([Tucker, 2007, Theorem 2, Page 188]) 
The number of selections with repetition of r objects chosen from 
n (distinct) types of objects is C(r + n − 1, r ). 
Proof. 
1 We use n-1 separators to separate the n types. 
2 The r objects to be selected can be represented by r !’s. 
n types, n-1 separators ! "# $ 
#!$!!" 
1st 
%%% 
#!!$!!!" 
2nd 
%%% 
· · · 
%%% 
#!$!!!" 
nth 
3 The number of sequences with r !’s and n-1 separators is 
& 
r + (n − 1) 
r 
' 
Dr. Ahmed Ashry “Algorithmic Combinatorics I” for 3rd Year Students — Lecture #3 3 (of 16)
Computer Science Division: CS301 
Example: Unordered Pairs of Numbers 
How many different domino faces are possible? 
We use the theorem to find the number of ways to construct an unordered 
pair of 2 numbers (with doubles allowed) between 0 and 6. This means: 
1 We need to select r = 2 numbers, 
2 With possible repetition, and 
3 From n = 7 types of numbers. 
" C(r + n − 1, r) = C(2 + 7 − 1, 2) = 8! 
2!×6! = 28 
Dr. Ahmed Ashry “Algorithmic Combinatorics I” for 3rd Year Students — Lecture #3 4 (of 16)
Computer Science Division: CS301 
Example: Selling Doughnuts 
How many ways are there to fill a box with a dozen doughnuts (i.e. 12 
pieces) chosen from 5 different varieties with the requirement that at 
least one doughnut of each variety is picked? 
Procedure: 
Pick one doughnut of each variety 
(N.B. this gives a total of five doughnuts in 1 way!!!) 
The remaining 7 doughnuts are selected with repetition 
Therefore, apply the theorem: 
n = 5 (types of doughnuts) 
r = 7 (objects needed to be selected) 
" C(r + n − 1, 
r) = 
! 
11 
7 
" 
= 330 
Dr. Ahmed Ashry “Algorithmic Combinatorics I” for 3rd Year Students — Lecture #3 5 (of 16)
Computer Science Division: CS301 
Example: Constrained Collections 
How many ways are there to pick a collection of exactly 10 balls from a 
pile of red balls, blue balls, and green balls if there must be: 
1 at least 5 red balls? 
2 at most 5 green balls? 
Solutions: 
1 Simply: 
Pick 5 red balls (in one way) 
Pick the remaining 5 balls arbitrarily in 
! 
5 +3 − 1 
5 
" 
= 21 ways 
2 Count !the complementary set: 
10 + 3 − 1 
10 
" 
= 66 ways to pick 10 balls without restriction 
! 
4 +3 − 1 
4 
" 
= 15 ways to pick a collection with " 6 green balls 
Answer: 66 − 15 = 51 ways (to get 10 balls with # 5 green balls) 
Dr. Ahmed Ashry “Algorithmic Combinatorics I” for 3rd Year Students — Lecture #3 6 (of 16)
Computer Science Division: CS301 
DISTRIBUTIONS: 
The “Distribution” Process 
Assigning (distinct/identical) objects to (distinct/identical) cells: 
(ordered/unordered) collections in containers? 
other constraints? 
Generally equivalent to selection or arrangement (with repetition). 
Usually broken into subcases. 
distribution of distinct objects corresponds to arrangements. 
distribution of identical objects corresponds to selections. 
Dr. Ahmed Ashry “Algorithmic Combinatorics I” for 3rd Year Students — Lecture #3 7 (of 16)
Computer Science Division: CS301 
Distinct Objects " Distinct Containers 
We have r distinct objects and n distinct cells 
" Each object can go in n places 
" Product rule: #n × n ×$!· · · × n" 
r−times 
= nr distributions 
Identical Objects " Distinct Containers 
We have r identical objects and n distinct cells 
" We choose r cells from the n in C(& 
n, r ) ways 
r + n − 1 
If repetition is allowed, " there are 
r 
' 
distributions 
Dr. Ahmed Ashry “Algorithmic Combinatorics I” for 3rd Year Students — Lecture #3 8 (of 16)
Computer Science Division: CS301 
Example: Diplomats 
1 How many ways are there to assign 100 different diplomats to 5 
different continents? 
2 How many ways if 20 diplomats must be assigned to each continent? 
Solution: 
1 The model for distributions tells us that: 
1 the r distinct objects correspond to the 100 diplomats 
2 the n distinct boxes correspond to the 5 continents 
3 " assignment can be done in nr = 5100 ways 
2 When distributing r different objects into n different boxes: 
1 if ri objects must go in box i, for 1 # i # n then 
there are P(r ; r1, . . . , 
rn) = 
r ! 
r1! × . . . × rn! 
" P(r ; r1, . . . , 
rn) = P(100; 20, 20, 20, 20, 20) = 
100! 
(20!)5 
Dr. Ahmed Ashry “Algorithmic Combinatorics I” for 3rd Year Students — Lecture #3 9 (of 16)
Computer Science Division: CS301 
Example: Candy Shop 
How many ways are there to distribute 20 (identical) sticks of red 
licorice and 15 (identical) sticks of black licorice among 5 children? 
1 Distribute the 20 red sticks in C(20 + 5 − 1, 20) = 10, 626 ways 
2 Distribute the 15 black sticks in C(15 + 5 − 1, 15) = 3, 876 ways. 
3 The product gives the number of ways to distribute all the candy. 
Dr. Ahmed Ashry “Algorithmic Combinatorics I” for 3rd Year Students — Lecture #3 10 (of 16)
Computer Science Division: CS301 
Constrained Collections: A General Note 
Theorem (Constrained Collections:a) 
a([Tucker, 2007, Example 4, Page 195]) 
The number of ways to distribute r identical objects into n distinct 
boxes with at least one object in each box is C(r − 1, n − 1). 
Proof. 
1 Put 1 object in each of the n boxes. 
2 Distribute the r − n (identical) objects in n (distinct) boxes in & 
(r − n) + n − 1 
(r − n) 
' 
= 
& 
r − 1 
(r − 1) − (r − n) 
' 
= 
& 
r − 1 
n − 1 
' 
ways. 
Dr. Ahmed Ashry “Algorithmic Combinatorics I” for 3rd Year Students — Lecture #3 11 (of 16)
Computer Science Division: CS301 
Application: Solving (Integer) Equations 
1 How many integer solutions are there to the equation 
x1 + x2 + x3 + x4 = 12, with xi $ 0. 
2 How many solutions with xi > 0? 
3 How many solutions with x1 $ 2, x2 $ 2, x3 $ 4, x4 $ 0? 
Integer solution means (ordered) integer values for the x’s. 
This kind of problems is modeled as “selection with repetition”: 
each xi represents the number of (identical) 1’s in box i 
(or represents the number of chosen objects of type i) 
1 Here, we have r = 12 ones, and n = 4 boxes. 
" The number of solutions is C(12 + 4 − 1, 12) = 
& 
15 
12 
' 
= 455. 
2 Here, we first put an object in each box =% r= 12 −4 = 8, n = 4. 
" The number of solutions is C(8 + 4 − 1, 8) = C(11, 3) = 165. 
3 Here, we first put objects in box i (as constrained): 
i.e. Put 2 in x1, 2 in x2, 4 in x3 
" The number of solutions is C((12 − 2 − 2 − 4) + 4 − 1, 6) = 35. 
Dr. Ahmed Ashry “Algorithmic Combinatorics I” for 3rd Year Students — Lecture #3 12 (of 16)
Computer Science Division: CS301 
Take Home Messages: 
1 Always keep in mind “WHY” the number of selections with 
repetition (of r objects chosen from n (distinct) types of 
objects is 
r+n−1 
r 
) 
. 
2 Distributions (Part I: distinct cells): 
Case/Distribution of: distinct objects identical objects 
“no repetition” P(n, r ) (C(n, r ) 
“unlimited repetition” nr 
r+n−1 
r 
) 
“restricted repetition” P(n; r1, . . . , rt ) — 
3 Remember 3 equivalent forms for selection with repetition: 
1 “selecting” r objects with repetition from n different types 
2 “distributing” r similar objects into n different boxes 
3 “solving” 
#n 
i=1 
xi = r (nonnegative integers) 
Dr. Ahmed Ashry “Algorithmic Combinatorics I” for 3rd Year Students — Lecture #3 13 (of 16)
Computer Science Division: CS301 
Homework #3: 
Letters & Envelopes 
We have 3 identical letters, and we want to placea them into 4 different 
colored envelopes: yellow, blue, red, and green. 
How many ways can the 3 letters be placed into the 4 envelopes? 
a(N.B. It is only possible to introduce one letter into each different envelope.) 
Think: 
Do we need 
(4 
3 
) 
, 
(4+3−1 
4 
) 
, or 
(3+4−1 
3 
) 
ways? 
Dr. Ahmed Ashry “Algorithmic Combinatorics I” for 3rd Year Students — Lecture #3 14 (of 16)
Computer Science Division: CS301 
Homework #3: 
Shirts & Children 
In how many different ways can 3 identical green shirts and 3 identical 
red shirts be distributed among 6 children such that each child receives a 
shirt? 
Think: 
Are we “selecting” 3 children in C(6, 3) = 6! 
3! 3! = 20 ways? 
Are we “arranging” 6 shirts in P(6; 3, 3) = 6! 
3! 3! = 20 ways? 
Why/Why not? 
Dr. Ahmed Ashry “Algorithmic Combinatorics I” for 3rd Year Students — Lecture #3 15 (of 16)
Computer Science Division: CS301 
References: 
Tucker, A. (2007). 
Applied combinatorics. 
Wiley, 5th edition. 
Dr. Ahmed Ashry “Algorithmic Combinatorics I” for 3rd Year Students — Lecture #3 16 (of 16)

More Related Content

What's hot

counting techniques
counting techniquescounting techniques
counting techniquesUnsa Shakir
 
PERMUTATION & COMBINATION
PERMUTATION & COMBINATIONPERMUTATION & COMBINATION
PERMUTATION & COMBINATIONPawan Mishra
 
Cbse Class 12 Maths Sample Paper 2012-13
Cbse Class 12 Maths Sample Paper 2012-13Cbse Class 12 Maths Sample Paper 2012-13
Cbse Class 12 Maths Sample Paper 2012-13Sunaina Rawat
 
3. permutation and combination
3. permutation and combination3. permutation and combination
3. permutation and combinationsmaplabu
 
Pre-Cal 40S Slides November 27, 2007
Pre-Cal 40S Slides November 27, 2007Pre-Cal 40S Slides November 27, 2007
Pre-Cal 40S Slides November 27, 2007Darren Kuropatwa
 
Notes on permutations and combinations
Notes on permutations and combinationsNotes on permutations and combinations
Notes on permutations and combinationsadeelashiq
 
permutation and combination
permutation and combinationpermutation and combination
permutation and combinationiqra university
 
Permutations and Combinations
Permutations and CombinationsPermutations and Combinations
Permutations and CombinationsAngel Willis
 
Factorials permutations and_combinations_using_excel
Factorials permutations and_combinations_using_excelFactorials permutations and_combinations_using_excel
Factorials permutations and_combinations_using_excelBrent Heard
 
Permutations and-combinations-maths
Permutations and-combinations-mathsPermutations and-combinations-maths
Permutations and-combinations-mathsMurugan Iron
 
Story Problems
Story ProblemsStory Problems
Story Problemspkarish
 
Combinations and permutations
Combinations and permutationsCombinations and permutations
Combinations and permutationsindu psthakur
 
Combinations and permutations(1)
Combinations and permutations(1)Combinations and permutations(1)
Combinations and permutations(1)Abebaw Abun Amanu
 
3.4 looking for real roots of real polynomials t
3.4 looking for real roots of real polynomials t3.4 looking for real roots of real polynomials t
3.4 looking for real roots of real polynomials tmath260
 

What's hot (17)

tree diagrams
 tree diagrams tree diagrams
tree diagrams
 
counting techniques
counting techniquescounting techniques
counting techniques
 
PERMUTATION & COMBINATION
PERMUTATION & COMBINATIONPERMUTATION & COMBINATION
PERMUTATION & COMBINATION
 
Cbse Class 12 Maths Sample Paper 2012-13
Cbse Class 12 Maths Sample Paper 2012-13Cbse Class 12 Maths Sample Paper 2012-13
Cbse Class 12 Maths Sample Paper 2012-13
 
Combinatorics
CombinatoricsCombinatorics
Combinatorics
 
3. permutation and combination
3. permutation and combination3. permutation and combination
3. permutation and combination
 
Pre-Cal 40S Slides November 27, 2007
Pre-Cal 40S Slides November 27, 2007Pre-Cal 40S Slides November 27, 2007
Pre-Cal 40S Slides November 27, 2007
 
Notes on permutations and combinations
Notes on permutations and combinationsNotes on permutations and combinations
Notes on permutations and combinations
 
permutation and combination
permutation and combinationpermutation and combination
permutation and combination
 
Counting DM
Counting DMCounting DM
Counting DM
 
Permutations and Combinations
Permutations and CombinationsPermutations and Combinations
Permutations and Combinations
 
Factorials permutations and_combinations_using_excel
Factorials permutations and_combinations_using_excelFactorials permutations and_combinations_using_excel
Factorials permutations and_combinations_using_excel
 
Permutations and-combinations-maths
Permutations and-combinations-mathsPermutations and-combinations-maths
Permutations and-combinations-maths
 
Story Problems
Story ProblemsStory Problems
Story Problems
 
Combinations and permutations
Combinations and permutationsCombinations and permutations
Combinations and permutations
 
Combinations and permutations(1)
Combinations and permutations(1)Combinations and permutations(1)
Combinations and permutations(1)
 
3.4 looking for real roots of real polynomials t
3.4 looking for real roots of real polynomials t3.4 looking for real roots of real polynomials t
3.4 looking for real roots of real polynomials t
 

Similar to Lecture #3: Algorithmic Combinatorics I "#FOSCS301"

Lecture Week 17 which hleps in study for logic and
Lecture Week 17 which hleps in study for logic andLecture Week 17 which hleps in study for logic and
Lecture Week 17 which hleps in study for logic andmanishhmishra001
 
counting principle.ppt
counting principle.pptcounting principle.ppt
counting principle.pptRizaCatli2
 
permutations power point
permutations power pointpermutations power point
permutations power pointAldrin Balenton
 
Probability and Statistics : Binomial Distribution notes ppt.pdf
Probability and Statistics : Binomial Distribution notes ppt.pdfProbability and Statistics : Binomial Distribution notes ppt.pdf
Probability and Statistics : Binomial Distribution notes ppt.pdfnomovi6416
 
Permutation combination
Permutation combinationPermutation combination
Permutation combinationlovemucheca
 
Counting technique
Counting techniqueCounting technique
Counting techniqueNadeem Uddin
 
Permutations and Combinations IIT JEE+Olympiad Lecture 4
Permutations and Combinations IIT JEE+Olympiad Lecture 4Permutations and Combinations IIT JEE+Olympiad Lecture 4
Permutations and Combinations IIT JEE+Olympiad Lecture 4Parth Nandedkar
 
Permutations and Combinations IIT JEE+Olympiad Lecture 3
Permutations and Combinations IIT JEE+Olympiad Lecture 3 Permutations and Combinations IIT JEE+Olympiad Lecture 3
Permutations and Combinations IIT JEE+Olympiad Lecture 3 Parth Nandedkar
 
Quant 125 awesome questions
Quant 125 awesome questionsQuant 125 awesome questions
Quant 125 awesome questionsRushabh Vora
 
Chapter-3-Sample-Space-of-Experiment.pdf
Chapter-3-Sample-Space-of-Experiment.pdfChapter-3-Sample-Space-of-Experiment.pdf
Chapter-3-Sample-Space-of-Experiment.pdfJuliusBoitizon
 
GMAT Quant Strategy- What to expect in Quantitative Reasoning Section on the ...
GMAT Quant Strategy- What to expect in Quantitative Reasoning Section on the ...GMAT Quant Strategy- What to expect in Quantitative Reasoning Section on the ...
GMAT Quant Strategy- What to expect in Quantitative Reasoning Section on the ...CrackVerbal
 
Introduction to Invariance Principle
Introduction to Invariance PrincipleIntroduction to Invariance Principle
Introduction to Invariance PrincipleFreeman Cheng
 
MATHEMATICS MODEL QUESTION PAPER FOR CBSE CLASS 10
MATHEMATICS MODEL QUESTION PAPER FOR CBSE CLASS 10MATHEMATICS MODEL QUESTION PAPER FOR CBSE CLASS 10
MATHEMATICS MODEL QUESTION PAPER FOR CBSE CLASS 10Bagalkot
 
Lecture Notes MTH302 Before MTT Myers.docx
Lecture Notes MTH302 Before MTT Myers.docxLecture Notes MTH302 Before MTT Myers.docx
Lecture Notes MTH302 Before MTT Myers.docxRaghavaReddy449756
 

Similar to Lecture #3: Algorithmic Combinatorics I "#FOSCS301" (20)

Lecture Week 17 which hleps in study for logic and
Lecture Week 17 which hleps in study for logic andLecture Week 17 which hleps in study for logic and
Lecture Week 17 which hleps in study for logic and
 
counting principle.ppt
counting principle.pptcounting principle.ppt
counting principle.ppt
 
permutations power point
permutations power pointpermutations power point
permutations power point
 
Practice Test 2 Solutions
Practice Test 2  SolutionsPractice Test 2  Solutions
Practice Test 2 Solutions
 
Probability and Statistics : Binomial Distribution notes ppt.pdf
Probability and Statistics : Binomial Distribution notes ppt.pdfProbability and Statistics : Binomial Distribution notes ppt.pdf
Probability and Statistics : Binomial Distribution notes ppt.pdf
 
Results of Round 1
Results of Round 1Results of Round 1
Results of Round 1
 
Permutation combination
Permutation combinationPermutation combination
Permutation combination
 
MFCS UNIT-III.pptx
MFCS UNIT-III.pptxMFCS UNIT-III.pptx
MFCS UNIT-III.pptx
 
Counting technique
Counting techniqueCounting technique
Counting technique
 
Internship exam round1
Internship exam round1Internship exam round1
Internship exam round1
 
Permutations and Combinations IIT JEE+Olympiad Lecture 4
Permutations and Combinations IIT JEE+Olympiad Lecture 4Permutations and Combinations IIT JEE+Olympiad Lecture 4
Permutations and Combinations IIT JEE+Olympiad Lecture 4
 
Permutations and Combinations IIT JEE+Olympiad Lecture 3
Permutations and Combinations IIT JEE+Olympiad Lecture 3 Permutations and Combinations IIT JEE+Olympiad Lecture 3
Permutations and Combinations IIT JEE+Olympiad Lecture 3
 
Permutations
PermutationsPermutations
Permutations
 
Quant 125 awesome questions
Quant 125 awesome questionsQuant 125 awesome questions
Quant 125 awesome questions
 
Chapter-3-Sample-Space-of-Experiment.pdf
Chapter-3-Sample-Space-of-Experiment.pdfChapter-3-Sample-Space-of-Experiment.pdf
Chapter-3-Sample-Space-of-Experiment.pdf
 
GMAT Quant Strategy- What to expect in Quantitative Reasoning Section on the ...
GMAT Quant Strategy- What to expect in Quantitative Reasoning Section on the ...GMAT Quant Strategy- What to expect in Quantitative Reasoning Section on the ...
GMAT Quant Strategy- What to expect in Quantitative Reasoning Section on the ...
 
Introduction to Invariance Principle
Introduction to Invariance PrincipleIntroduction to Invariance Principle
Introduction to Invariance Principle
 
MATHEMATICS MODEL QUESTION PAPER FOR CBSE CLASS 10
MATHEMATICS MODEL QUESTION PAPER FOR CBSE CLASS 10MATHEMATICS MODEL QUESTION PAPER FOR CBSE CLASS 10
MATHEMATICS MODEL QUESTION PAPER FOR CBSE CLASS 10
 
Probability and statistics assignment help
Probability and statistics assignment helpProbability and statistics assignment help
Probability and statistics assignment help
 
Lecture Notes MTH302 Before MTT Myers.docx
Lecture Notes MTH302 Before MTT Myers.docxLecture Notes MTH302 Before MTT Myers.docx
Lecture Notes MTH302 Before MTT Myers.docx
 

Recently uploaded

On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfDr Vijay Vishwakarma
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 

Recently uploaded (20)

On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 

Lecture #3: Algorithmic Combinatorics I "#FOSCS301"

  • 1. Computer Science Division: CS301 Course CS301, Part: “ALGORITHMIC COMBINATORICS I” ( 3rd Year Students ) Prepared by: http://www.researchgate.net/profile/Ahmed_Abdel-Fattah Lecture #3 N.B. The Mid-Term Exam will be held on 08-NOV-2014 (and it includes this lecture) Dr. Ahmed Ashry “Algorithmic Combinatorics I” for 3rd Year Students — Lecture #3 1 (of 16)
  • 2. Computer Science Division: CS301 Selections with REPETITIONS: When an object can be chosen more than once. Example: Unordered Pairs of Numbers A domino is a rectangular piece whose top face is divided into 2 squares. Each of the squares contains between 0 (blank) and 6 dots. How many different domino faces are possible? Dr. Ahmed Ashry “Algorithmic Combinatorics I” for 3rd Year Students — Lecture #3 2 (of 16)
  • 3. Computer Science Division: CS301 Theorem (Selections with Unlimited Repetitions:a) a([Tucker, 2007, Theorem 2, Page 188]) The number of selections with repetition of r objects chosen from n (distinct) types of objects is C(r + n − 1, r ). Proof. 1 We use n-1 separators to separate the n types. 2 The r objects to be selected can be represented by r !’s. n types, n-1 separators ! "# $ #!$!!" 1st %%% #!!$!!!" 2nd %%% · · · %%% #!$!!!" nth 3 The number of sequences with r !’s and n-1 separators is & r + (n − 1) r ' Dr. Ahmed Ashry “Algorithmic Combinatorics I” for 3rd Year Students — Lecture #3 3 (of 16)
  • 4. Computer Science Division: CS301 Example: Unordered Pairs of Numbers How many different domino faces are possible? We use the theorem to find the number of ways to construct an unordered pair of 2 numbers (with doubles allowed) between 0 and 6. This means: 1 We need to select r = 2 numbers, 2 With possible repetition, and 3 From n = 7 types of numbers. " C(r + n − 1, r) = C(2 + 7 − 1, 2) = 8! 2!×6! = 28 Dr. Ahmed Ashry “Algorithmic Combinatorics I” for 3rd Year Students — Lecture #3 4 (of 16)
  • 5. Computer Science Division: CS301 Example: Selling Doughnuts How many ways are there to fill a box with a dozen doughnuts (i.e. 12 pieces) chosen from 5 different varieties with the requirement that at least one doughnut of each variety is picked? Procedure: Pick one doughnut of each variety (N.B. this gives a total of five doughnuts in 1 way!!!) The remaining 7 doughnuts are selected with repetition Therefore, apply the theorem: n = 5 (types of doughnuts) r = 7 (objects needed to be selected) " C(r + n − 1, r) = ! 11 7 " = 330 Dr. Ahmed Ashry “Algorithmic Combinatorics I” for 3rd Year Students — Lecture #3 5 (of 16)
  • 6. Computer Science Division: CS301 Example: Constrained Collections How many ways are there to pick a collection of exactly 10 balls from a pile of red balls, blue balls, and green balls if there must be: 1 at least 5 red balls? 2 at most 5 green balls? Solutions: 1 Simply: Pick 5 red balls (in one way) Pick the remaining 5 balls arbitrarily in ! 5 +3 − 1 5 " = 21 ways 2 Count !the complementary set: 10 + 3 − 1 10 " = 66 ways to pick 10 balls without restriction ! 4 +3 − 1 4 " = 15 ways to pick a collection with " 6 green balls Answer: 66 − 15 = 51 ways (to get 10 balls with # 5 green balls) Dr. Ahmed Ashry “Algorithmic Combinatorics I” for 3rd Year Students — Lecture #3 6 (of 16)
  • 7. Computer Science Division: CS301 DISTRIBUTIONS: The “Distribution” Process Assigning (distinct/identical) objects to (distinct/identical) cells: (ordered/unordered) collections in containers? other constraints? Generally equivalent to selection or arrangement (with repetition). Usually broken into subcases. distribution of distinct objects corresponds to arrangements. distribution of identical objects corresponds to selections. Dr. Ahmed Ashry “Algorithmic Combinatorics I” for 3rd Year Students — Lecture #3 7 (of 16)
  • 8. Computer Science Division: CS301 Distinct Objects " Distinct Containers We have r distinct objects and n distinct cells " Each object can go in n places " Product rule: #n × n ×$!· · · × n" r−times = nr distributions Identical Objects " Distinct Containers We have r identical objects and n distinct cells " We choose r cells from the n in C(& n, r ) ways r + n − 1 If repetition is allowed, " there are r ' distributions Dr. Ahmed Ashry “Algorithmic Combinatorics I” for 3rd Year Students — Lecture #3 8 (of 16)
  • 9. Computer Science Division: CS301 Example: Diplomats 1 How many ways are there to assign 100 different diplomats to 5 different continents? 2 How many ways if 20 diplomats must be assigned to each continent? Solution: 1 The model for distributions tells us that: 1 the r distinct objects correspond to the 100 diplomats 2 the n distinct boxes correspond to the 5 continents 3 " assignment can be done in nr = 5100 ways 2 When distributing r different objects into n different boxes: 1 if ri objects must go in box i, for 1 # i # n then there are P(r ; r1, . . . , rn) = r ! r1! × . . . × rn! " P(r ; r1, . . . , rn) = P(100; 20, 20, 20, 20, 20) = 100! (20!)5 Dr. Ahmed Ashry “Algorithmic Combinatorics I” for 3rd Year Students — Lecture #3 9 (of 16)
  • 10. Computer Science Division: CS301 Example: Candy Shop How many ways are there to distribute 20 (identical) sticks of red licorice and 15 (identical) sticks of black licorice among 5 children? 1 Distribute the 20 red sticks in C(20 + 5 − 1, 20) = 10, 626 ways 2 Distribute the 15 black sticks in C(15 + 5 − 1, 15) = 3, 876 ways. 3 The product gives the number of ways to distribute all the candy. Dr. Ahmed Ashry “Algorithmic Combinatorics I” for 3rd Year Students — Lecture #3 10 (of 16)
  • 11. Computer Science Division: CS301 Constrained Collections: A General Note Theorem (Constrained Collections:a) a([Tucker, 2007, Example 4, Page 195]) The number of ways to distribute r identical objects into n distinct boxes with at least one object in each box is C(r − 1, n − 1). Proof. 1 Put 1 object in each of the n boxes. 2 Distribute the r − n (identical) objects in n (distinct) boxes in & (r − n) + n − 1 (r − n) ' = & r − 1 (r − 1) − (r − n) ' = & r − 1 n − 1 ' ways. Dr. Ahmed Ashry “Algorithmic Combinatorics I” for 3rd Year Students — Lecture #3 11 (of 16)
  • 12. Computer Science Division: CS301 Application: Solving (Integer) Equations 1 How many integer solutions are there to the equation x1 + x2 + x3 + x4 = 12, with xi $ 0. 2 How many solutions with xi > 0? 3 How many solutions with x1 $ 2, x2 $ 2, x3 $ 4, x4 $ 0? Integer solution means (ordered) integer values for the x’s. This kind of problems is modeled as “selection with repetition”: each xi represents the number of (identical) 1’s in box i (or represents the number of chosen objects of type i) 1 Here, we have r = 12 ones, and n = 4 boxes. " The number of solutions is C(12 + 4 − 1, 12) = & 15 12 ' = 455. 2 Here, we first put an object in each box =% r= 12 −4 = 8, n = 4. " The number of solutions is C(8 + 4 − 1, 8) = C(11, 3) = 165. 3 Here, we first put objects in box i (as constrained): i.e. Put 2 in x1, 2 in x2, 4 in x3 " The number of solutions is C((12 − 2 − 2 − 4) + 4 − 1, 6) = 35. Dr. Ahmed Ashry “Algorithmic Combinatorics I” for 3rd Year Students — Lecture #3 12 (of 16)
  • 13. Computer Science Division: CS301 Take Home Messages: 1 Always keep in mind “WHY” the number of selections with repetition (of r objects chosen from n (distinct) types of objects is r+n−1 r ) . 2 Distributions (Part I: distinct cells): Case/Distribution of: distinct objects identical objects “no repetition” P(n, r ) (C(n, r ) “unlimited repetition” nr r+n−1 r ) “restricted repetition” P(n; r1, . . . , rt ) — 3 Remember 3 equivalent forms for selection with repetition: 1 “selecting” r objects with repetition from n different types 2 “distributing” r similar objects into n different boxes 3 “solving” #n i=1 xi = r (nonnegative integers) Dr. Ahmed Ashry “Algorithmic Combinatorics I” for 3rd Year Students — Lecture #3 13 (of 16)
  • 14. Computer Science Division: CS301 Homework #3: Letters & Envelopes We have 3 identical letters, and we want to placea them into 4 different colored envelopes: yellow, blue, red, and green. How many ways can the 3 letters be placed into the 4 envelopes? a(N.B. It is only possible to introduce one letter into each different envelope.) Think: Do we need (4 3 ) , (4+3−1 4 ) , or (3+4−1 3 ) ways? Dr. Ahmed Ashry “Algorithmic Combinatorics I” for 3rd Year Students — Lecture #3 14 (of 16)
  • 15. Computer Science Division: CS301 Homework #3: Shirts & Children In how many different ways can 3 identical green shirts and 3 identical red shirts be distributed among 6 children such that each child receives a shirt? Think: Are we “selecting” 3 children in C(6, 3) = 6! 3! 3! = 20 ways? Are we “arranging” 6 shirts in P(6; 3, 3) = 6! 3! 3! = 20 ways? Why/Why not? Dr. Ahmed Ashry “Algorithmic Combinatorics I” for 3rd Year Students — Lecture #3 15 (of 16)
  • 16. Computer Science Division: CS301 References: Tucker, A. (2007). Applied combinatorics. Wiley, 5th edition. Dr. Ahmed Ashry “Algorithmic Combinatorics I” for 3rd Year Students — Lecture #3 16 (of 16)