Permutation and Combination: Distribution of Balls into Boxes

In this article, we are going to learn how to calculate the number of ways in which x balls can be distributed in n boxes. This is one confusing topic which is hardly understood by students. But once mastered, it is the easiest topic of Permutation and Combination.
There can be 4 cases pertaining to this problem.
Case 1: Balls are same; boxes are same
Case 2: Balls are same; boxes are different
Case 3: Balls are different; boxes are same
Case 4: Balls are different; boxes are different
To understand it better, let's take an example.
Example: What is the number of ways in which you can distribute 5 balls in 3 boxes when:
  • Balls are same; boxes are same
  • Balls are same; boxes are different
  • Balls are different; boxes are same
  • Balls are different; boxes are different
Solution:
GroupPermutation of balls (Number of ways of grouping)Ways of Distribution of boxesTotal number
0,0,5111*1=1
0,1,4111*1=1
0,2,3111*1=1
1,1,3111*1=1
1,2,2111*1=1
Hence, total number of ways = 1+1+1+1+1=5.
  • When Balls are same; boxes are same
GroupPermutation of balls(Number of ways of grouping)Ways of Distribution of boxesTotal number
0,0,513!/2!=31*3=3
0,1,413!=61*6=6
0,2,313!=61*6=6
1,1,313!/2!=31*3=3
1,2,213!/2!=31*3=3
Hence, total number of ways = 3+6+6+3+3=21.
  • Balls are same; boxes are different
GroupPermutation of balls(Number of ways of grouping)Ways of Distribution of boxesTotal number
0,0,5111*1
0,1,45C1*4C4=515*1=5
0,2,35C2* 3C3=10110*1=10
1,1,35C3* (2!/2)=10110*1=10
1,2,25C1 *(4!/(2!*2!*2)=15115*1=15
Hence, total number of ways = 1+5+10+10+15=41
  • Balls are different; boxes are same
GroupPermutation of balls(Number of ways of grouping)Ways of Distribution of boxesTotal number
0,0,513!/2!=31*3=3
0,1,45C1 = 53!=65*6=30
0,2,35C2 = 103!=610*6=60
1,1,35C3* (2C1/2) = 103!=610*6=60
1,2,25C1 *(4!/2!*2!*2)=153!=615*6=90
Hence, total number of ways = 3+30+60+60+90= 243.
  • Balls are different; boxes are different
Suggested Reading :
Learn the fundamental concepts of Permutation and Combination
Feel free to share your doubts from Permutations and Combinations in the comments section below.