Lesson Stars and bars method for Combinatorics problems
Algebra
->
Customizable Word Problem Solvers
->
Misc
-> Lesson Stars and bars method for Combinatorics problems
Log On
Ad:
Over 600 Algebra Word Problems at edhelper.com
Word Problems: Miscellaneous Word Problems
Word
Solvers
Solvers
Lessons
Lessons
Answers archive
Answers
Source code of 'Stars and bars method for Combinatorics problems'
This Lesson (Stars and bars method for Combinatorics problems)
was created by by
ikleyn(52781)
:
View Source
,
Show
About ikleyn
:
<H2>Stars and bars method for Combinatorics problems</H2> The problems and the method of their solutions in this lesson are of highest peaks in Combinatorics. They are at the level of a School Math circle at the local or (better to say) of a renowned University. <H3>Problem 1</H3>How many solutions (using only positive integers) are there to the following equation x1 + x2 + x3 + x4 + x5 = 36 ? <B>Solution</B> <pre> x1 + x2 + x3 + x4 + x5 = 36 (1) Imagine 36 marbles on the table, placed in one straight line with small gaps between them. Imagine you have 6 numbered bars, of which you place the first bar (bar N1) before the first marble and the last bar (bar N6) after the last marble in the row. Let {{{x[1]}}}, {{{x[2]}}}, {{{x[3]}}}, {{{x[4]}}}, {{{x[5]}}} be some solution to the given equation. You then place bar N2 after {{{x[1]}}}-th marble in the gap in the row of marbles; then you count next {{{x[2]}}} marbles in the row of marbles after bar N2 and place bar N3 in the gap there; then you count next {{{x[3]}}} marbles in the row of marbles after bar N3 and place bar N4 in the gap there; finally, you count next {{{x[4]}}} marbles in the row of marbles after bar N4 and place bar N5 in the gap there. At this moment, all 36 marbles are divided in 5 groups between bars (1-2), (2-3), (3-4), (4,5) and (5,6). So, having the solution to equation (1) in positive integer number, you place 4 bars N2, N3, N4 and N5 in their corresponding positions in gaps in the row of marbles. Vise versa, if you place 4 bars B2, B3, B4 and B5 in gaps in the row of 36 marbles, you divide marbles in 5 groups, and the numbers of marbles in each group form the solution to equation (1). Thus, there is one-to-one correspondence between the set of solutions to equation (1) in positive integer numbers, from one side, and all different possible placings of 4 bars in gaps in the row of 36 marbles. Also note that no one pair of bars goes to any single gap between marbles, because the numbers {{{x[1]}}}, {{{x[2]}}}, {{{x[3]}}}, {{{x[4]}}}, {{{x[5]}}} all are positive (!) Thus, the number of solutions to equation (1) is equal to the number of COMBINATIONS of 35 (= 36-1) gaps taken 4 at a time. Hence, the number of all possible solutions to equation (1) in positive integer numbers is equal to {{{C[35]^4}}} = {{{(35*34*33*32)/(1*2*3*4)}}} = 52360. <U>ANSWER</U>. The number of different solutions to equation (1) is {{{C[35]^4}}} = 52360. </pre> Solved. ------------------ <pre> More general problem to find the number of positive integer solution to equation {{{x[1]}}} + {{{x[2]}}} + {{{x[3]}}} + . . . + {{{x[k]}}} = n where k <= n, can be solved in the same way and has the answer {{{C[n-1]^(k-1)}}}. We have then (n-1) gaps between "n" "marbles" and (k-1) movable dividing bars. The method I used in the solution is called the "<U>method of bars and stars</U>". You can read about it in this Wikipedia article https://en.wikipedia.org/wiki/Stars_and_bars_%28combinatorics%29 </pre> The second problem seems to be similar to the first one, but is different in some important aspects. <H3>Problem 2</H3>How many solutions (using non-negative integers) are there to the following equation x1 + x2 + x3 + x4 + x5 = 36 ? <B>Solution</B> <pre> x1 + x2 + x3 + x4 + x5 = 36 (1) Imagine 36 marbles on the table, placed in one straight line with small gaps between them. Imagine you have 6 numbered bars, of which you place the first bar (bar N1) before the first marble and the last bar (bar N6) after the last marble in the row. Let {{{x[1]}}}, {{{x[2]}}}, {{{x[3]}}}, {{{x[4]}}}, {{{x[5]}}} be some solution to the given equation. You then place bar N2 after {{{x[1]}}}-th marble in the gap in the row of marbles; then you count next {{{x[2]}}} marbles in the row of marbles after bar N2 and place bar N3 in the gap there; then you count next {{{x[3]}}} marbles in the row of marbles after bar N3 and place bar N4 in the gap there; finally, you count next {{{x[4]}}} marbles in the row of marbles after bar N4 and place bar N5 in the gap there. At this moment, all 36 marbles are divided in 5 groups between bars (1-2), (2-3), (3-4), (4,5) and (5,6). Notice that if some {{{x[k]}}} is zero, then the corresponding bars go to the common respective gap. In particular, if {{{x[1]}}} = 0, then the bars N1 and N2 are placed in one common gap close to each other BEFORE the first marble (!) So, having the solution to equation (1) in non-negative positive integer number, you place 4 bars N2, N3, N4 and N5 in their corresponding positions in gaps in the row of marbles. Vise versa, if you place 4 bars B2, B3, B4 and B5 in gaps in the row of 36 marbles, you divide marbles in 5 groups, and the numbers of marbles in each group form the solution to equation (1). Thus, there is one-to-one correspondence between the set of solutions to equation (1) in non-negative integer numbers, from one side, and all different possible placings of 4 bars in 36 gaps in the row between 36 marbles, plus one gap before the 1-st marble. Thus we have 36+4 = 40 entities, 36 gaps and 4 bars; 36 gaps are indistinguishable and 4 movable bars are indistinguishable, too. The number of all possible indistinguishable arrangements of 40 items of two types with 36 indistinguishable of one type and 4 indistinguishable of the other type is {{{40!/(35!*4!)}}} = {{{(40*39*38*37)/(1*2*3*4)}}} = 91390. Hence, the number of all possible solutions to equation (1) in positive integer numbers is equal to {{{(40*39*38*37)/(1*2*3*4)}}} = 91390. <U>ANSWER</U>. The number of different solutions to equation (1) is 91390. </pre> Solved. ------------------ <pre> More general problem to find the number of non-negative integer solution to equation {{{x[1]}}} + {{{x[2]}}} + {{{x[3]}}} + . . . + {{{x[k]}}} = n where k <= n, can be solved in the same way and has the answer {{{(n+k-1)!/(n!*(k-1)!)}}}. We have then n gaps between "n" "marbles" (including one gap BEFORE the first marble) and (k-1) movable dividing bars. The method I used in the solution is called the "<U>method of bars and stars</U>". You can read about it in this Wikipedia article https://en.wikipedia.org/wiki/Stars_and_bars_%28combinatorics%29 </pre> My other additional lessons on Miscellaneous word problems in this site are - <A HREF=https://www.algebra.com/algebra/homework/word/misc/I-do-not-have-enough-savings-now.lesson>I do not have enough savings now</A> - <A HREF=https://www.algebra.com/algebra/homework/word/misc/In-a-jar-all-but-6-are-red-marbles.lesson>In a jar, all but 6 are red marbles</A> - <A HREF=https://www.algebra.com/algebra/homework/word/misc/How-many-boys-and-how-many-girls-are-there-in-a-family.lesson>How many boys and how many girls are there in a family ?</A> - <A HREF=https://www.algebra.com/algebra/homework/word/misc/What-is--the-last-digit-of-the-number-a%5En-.lesson>What is the last digit of the number a^n ?</A> - <A HREF=https://www.algebra.com/algebra/homework/word/misc/Find-the-last-three-digits-of-these-numbers-.lesson>Find the last three digits of these numbers</A> - <A HREF=https://www.algebra.com/algebra/homework/word/misc/What-are-the-two-last-digits-of-the-number-3%5E123%2B7%5E123%2B9%5E123.lesson>What are the last two digits of the number 3^123 + 7^123 + 9^123 ?</A> - <A HREF=https://www.algebra.com/algebra/homework/word/misc/Really-complicated-logic-problem.lesson>Advanced logical problems</A> - <A HREF=https://www.algebra.com/algebra/homework/word/misc/Prove-that-if-a-b-and-c-are-the-sides-of-a-triangle-.lesson>Prove that if a, b, and c are the sides of a triangle, then so are sqrt(a), sqrt(b) and sqrt(c)</A> - <A HREF=https://www.algebra.com/algebra/homework/word/misc/Calculus-optimization-problems-for-shapes-in-2D-plane.lesson>Calculus optimization problems for shapes in 2D plane</A> - <A HREF=https://www.algebra.com/algebra/homework/word/misc/Calculus-optimization-problems.lesson>Calculus optimization problems for 3D shapes</A> - <A HREF=https://www.algebra.com/algebra/homework/word/misc/Solving-some-linear-minimax-problems-in-3D-space.lesson>Solving some linear minimax problems in 3D space</A> - <A HREF=https://www.algebra.com/algebra/homework/word/misc/Solving-one-non-linear-minimax-problem-in-3D-space.lesson>Solving one non-linear minimax problems in 3D space</A> - <A HREF=https://www.algebra.com/algebra/homework/word/misc/Solving-linear-minimax-problem-in-three-unknowns-by-the-simplex-method.lesson>Solving linear minimax problem in three unknowns by the simplex method</A> - <A HREF=https://www.algebra.com/algebra/homework/word/misc/The-pigeonhole-principle-problems.lesson>The "pigeonhole principle" problems</A> - <A HREF=https://www.algebra.com/algebra/homework/word/misc/In-the-worst-case.lesson>In the worst case</A> - <A HREF=https://www.algebra.com/algebra/homework/word/misc/Page-numbers-on-the-left-and-right-facing-pages-of-an-opened-book.lesson>Page numbers on the left and right facing pages of an opened book</A> - <A HREF=https://www.algebra.com/algebra/homework/word/misc/Selected-problems-on-counting-elements-in-subsets-of-a-given-finite-set.lesson>Selected problems on counting elements in subsets of a given finite set</A> - <A HREF=https://www.algebra.com/algebra/homework/word/misc/How-many-numbers-from-1-to-300-are-divisible-by-X.lesson>How many integer numbers in the range 1-300 are divisible by at least one of the integers 4, 6 and 15 ?</A> - <A HREF=https://www.algebra.com/algebra/homework/word/misc/Nice-problems-to-setup-them-using-Venn-diagram.lesson>Nice problems to setup them using Venn diagram</A> - <A HREF=https://www.algebra.com/algebra/homework/word/misc/Wrapping-a-gift.lesson>Wrapping a gift</A> - <A HREF=https://www.algebra.com/algebra/homework/word/misc/In-preparation-for-Halloween-.lesson>In preparation for Halloween</A> - <A HREF=https://www.algebra.com/algebra/homework/word/misc/Nice-entertaiment-problems-related-to-divisibility-numbers.lesson>Nice entertainment problems related to divisibility property</A> - <A HREF=https://www.algebra.com/algebra/homework/word/misc/Olimpiad-level-Math-problem-on-caves-and-bats.lesson>Math Olympiad level problem on caves and bats</A> - <A HREF=https://www.algebra.com/algebra/homework/word/misc/Math-Olympiad-level-problem-on-caught-fishes.lesson>Math Olympiad level problem on caught fishes</A> - <A HREF=https://www.algebra.com/algebra/homework/word/misc/Math-Olympiad-level-problem-on-pigeonhole-principle.lesson>Math Olympiad level problem on pigeonhole principle</A> - <A HREF=https://www.algebra.com/algebra/homework/word/misc/Math-Olympiad-level-problem-on-placing-books-in-bookcase.lesson>Math Olympiad level problem on placing books in bookcase</A> - <A HREF=https://www.algebra.com/algebra/homework/word/misc/OVERVIEW-of-additional-lessons-on-Miscellaneous-word-problems.lesson>OVERVIEW of additional lessons on Miscellaneous word problems</A> Use this file/link <A HREF=https://www.algebra.com/algebra/homework/quadratic/lessons/ALGEBRA-I-YOUR-ONLINE-TEXTBOOK.lesson>ALGEBRA-I - YOUR ONLINE TEXTBOOK</A> to navigate over all topics and lessons of the online textbook ALGEBRA-I. Use this file/link <A HREF=https://www.algebra.com/algebra/homework/complex/ALGEBRA-II-YOUR-ONLINE-TEXTBOOK.lesson>ALGEBRA-II - YOUR ONLINE TEXTBOOK</A> to navigate over all topics and lessons of the online textbook ALGEBRA-II.