Counting unordered lists (CSCI 2824, Spring 2015)On this page, we consider the problem of counting the number of ordered and unordered lists. The materials correspond to Sect 5.4 of the textbook. Recap on counting ordered listsExample 1How many ordered lists of 10 letters from Solution
Example 2Similarly, the number of ordered lists of 10 English letters with
exactly 3 Counting unordered listsExample 3How many ways can I distribute 10 candies among Alice, Bob and Carlos, so that each person has at least 1 candy? Using the stars and bars technique
We can reason use the stars and bars diagram.
Example 4How many ways can I distribute 10 candies among Alice, Bob and Carlos, with the possibility that someone can have no candies? Using the stars and bars technique
Consider the following scenario:
Using the reasoning from Example 3, we see that there are Example 5 (NEW!)How many ways can I distribute 20 candies among Alice, Bob and Carlos, so that each person has at least 3 candies? Answer
To ensure that everyone gets at least 3 candies, we can do the following:
So the number of distinct distributions is equal to the number of ways to distribute 11 candies among 3 people, which is ![]() Example 6 (NEW!)What is the cardinality of the set ![]() Answer
Counting the number of elements of the above set is the same as counting the number of ways to distribute 30 apples among 4 people so that everyone gets at least 1 apple, with:
So then we can use the stars and bars method as in Example 3, and the answer would be
Example 7 (NEW!)What is the cardinality of the set ![]() Answer
Counting the number of elements of the above set is the same as counting the number of ways to distribute 30 apples among 4 people (though someone could get none), with:
So then we can use the stars and bars method as in Example 4, and the answer would be
Example 8 (NEW!)I have a box of dollar bills. In this box, there are 10 $1 bills, 20 $10 bills and 30 $20 bills. From the box, I grab 5 bills all at onces. How many possible outcomes are there? Note that I can record all the possible results in a table like this:
For instance, the first row says I get two $1 bills, one $10 bill and one $20 bill; the second row says I get one $1 bill and three $20 bills. (I probably should list my results in a more systematic way than the above though!) Note that in this table each row contains three numbers that sum to 5. The point is that we can think of this counting problem as finding all the possible ways to distribute 5 objects (in this case bills) among 3 different bins. Answer
Hence the answer can be obtained using the stars and bars technique: ![]() Example 9 (NEW!)From a big of 8 (identical) red marbles, 5 (identical) green marbles 3 (identical) blue marbles, we grab 4 marbles all at once. How many different outcomes (in terms of color combinations) are there? Answer
Like Example 8, this counting problem is equivalent to counting the number of ways to distribute 4 objects among 3 different bins (for the three different colors), with the restriction that the last bin (for the color green) can hold at most 3 objects. Without any restriction, there are
There is one outcome that we don't want:
that all 4 objects go into the green bin.
Hence the answer is Placing
|
n | r | Time used by recursion | Time used by explicit formula |
20 | 10 | 0.12 s | 1.00e-06 s |
30 | 10 | 2.10 s | 1.00e-06 s |
40 | 10 | 22.0 s | 1.00e-06 s |