How many ways are there to place n indistinguishable balls

In order to continue enjoying our site, we ask that you confirm your identity as a human. Thank you very much for your cooperation.

View Discussion

Improve Article

Save Article

Like Article

  • Read
  • Discuss
  • View Discussion

    Improve Article

    Save Article

    Like Article

    Prerequisite – Generalized PnC Set 1Combinatorial problems can be rephrased in several different ways, the most common of which is in terms of distributing balls into boxes. So we must become familiar with the terminology to be able to solve problems.

    The balls and boxes can be either distinguishable or indistinguishable and the distribution can take place either with or without exclusion.

    The term exclusion means that no box can contain more than one ball, and similarly, if the problem states the distribution is without exclusion it means that a box may contain more than one ball.

    Throughout this article consider that there are

    How many ways are there to place n indistinguishable balls
    balls and
    How many ways are there to place n indistinguishable balls
    boxes.

    1. Distinguishable balls and Distinguishable boxes –

    With Exclusion – In case of exclusion, distribution is the same as counting

    How many ways are there to place n indistinguishable balls
    -permutations, as there are
    How many ways are there to place n indistinguishable balls
    choices for the first ball,
    How many ways are there to place n indistinguishable balls
    for the second and so on.
    Without Exclusion – When the distribution is without exclusion, i.e. there is no restriction on the minimum number of balls a box has to have, the number of ways –
    How many ways are there to place n indistinguishable balls
    . This is because every ball has
    How many ways are there to place n indistinguishable balls
    choices.
    Fixed number of balls – If the distribution is such that each box should only have a fixed number of balls then the number of ways is-
    How many ways are there to place n indistinguishable balls
    where
    How many ways are there to place n indistinguishable balls
    is the number of balls to be put in the
    How many ways are there to place n indistinguishable balls
    box.

    • Example 1 – In how many ways can 10 prizes be distributed among 5 people without exclusion?
    • Solution – This situation is analogous to distributing distinct balls into distinct boxes without exclusion. For every prize there are 5 choices of people who can receive it. So the number of ways of distributing the prizes is-
      How many ways are there to place n indistinguishable balls
      .
    • Example 2 – How many ways are there to distribute hands of 5 cards to each of four players from a standard deck of 52 cards?
    • Solution – This situation is analogous to distributing distinct balls into distinct boxes where each box must have a certain number of balls.The first person can get the cards in C(52,5) ways.The second person can get the cards in C(47,5) ways and so on till the fourth person can get the cards in C(37,5) ways. After 20 balls(cards) have been distributed, the remaining cards form the fifth box (or player).This can be solved with the product rule, total ways-

      =

      How many ways are there to place n indistinguishable balls

      =

      How many ways are there to place n indistinguishable balls

      =

      How many ways are there to place n indistinguishable balls

      This could also be solved using the formula mentioned above using group sizes 5,5,5,5 and 32.

    2. Indistinguishable balls and Distinguishable boxes –

    Counting the number of ways of placing indistinguishable balls into distinguishable boxes with exclusion is the same as counting

    How many ways are there to place n indistinguishable balls
    -combinations without repetition of elements. But if the distribution is without exclusion then the problem is the same as counting the number of
    How many ways are there to place n indistinguishable balls
    -combinations where elements can be repeated. Refer Generalized PnC Part-1 for more on this topic.

    3. Distinguishable balls and Indistinguishable boxes –

    There is no simple closed formula for counting the number of ways of distributing distinguishable balls into indistinguishable boxes, but there is a complex one involving Stirling number of the second kind.
    The Stirling number is denoted by

    How many ways are there to place n indistinguishable balls
    where
    How many ways are there to place n indistinguishable balls
    is the number of balls and
    How many ways are there to place n indistinguishable balls
    is the number of non-empty boxes.
    How many ways are there to place n indistinguishable balls

    So the number of ways is-
    How many ways are there to place n indistinguishable balls

    4. Indistinguishable balls and Indistinguishable boxes –

    Counting the number of ways of distributing indistinguishable balls into indistinguishable objects is analogous to finding the number of partitions of a positive integer. No simple formula exists for finding the number of partitions of a positive integer.

    For both of the above cases, enumeration of all ways is sometimes easier than finding a closed formula which gives the same result.

    • Example 1 – How many ways are there to put four different balls into three indistinguishable offices without exclusion?
    • Solution – Enumerating all possible scenarios instead of using the Stirling Formula is easier. Let the four balls be
      How many ways are there to place n indistinguishable balls
      .
      All balls in one box –
      How many ways are there to place n indistinguishable balls
      3 balls in one box and 1 in another-

      How many ways are there to place n indistinguishable balls

      2 balls in one box and 2 in another-

      How many ways are there to place n indistinguishable balls

      2 balls in one box and 1 each in the remaining boxes-

      How many ways are there to place n indistinguishable balls


      How many ways are there to place n indistinguishable balls

      This gives us a total of- 1 + 3 + 4 + 6 = 14 ways.
    • Example 2 – How many ways are there to put 4 indistinguishable balls into 3 indistinguishable boxes?
    • Solution – As mentioned above, the above problem is analogous to finding the number of partitions of the positive integer 4, where the number of partitions is less than or equal to 3.Enumerating all possible ways-All four balls in one box – 43 balls in one box, 1 ball in one – 3,12 balls in two boxes – 2,22 balls in 1 box, 1 ball in two boxes each – 2,1,1Total number of ways = 4It is similar to finding the number of partitions of 4-4 = 43 + 1 = 42 + 2 = 4

      2 + 1 + 1 = 4

    GATE CS Corner Questions

    Practicing the following questions will help you test your knowledge. All questions have been asked in GATE in previous years or in GATE Mock Tests. It is highly recommended that you practice them.

    1. GATE CS 2003, Question 34
    2. GATE CS 2015 Set-3, Question 15

    References-

    Partition Number Theory – Wikipedia
    Discrete Mathematics and its Applications, by Kenneth H Rosen

    This article is contributed by Chirag Manwani. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to . See your article appearing on the GeeksforGeeks main page and help other Geeks.

    Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.