The materials on this page restrict themselves to countable sets. We define a countable set as follows:
enumerability.
Let S be a set. Then S is countably infinite if, and only if, #(S)=#(N).
Assignments
We begin by defining assignments, just to to make our discussion a bit more efficient.
assignment. Let A and B be sets. Then an assignmentf:Aβ¦B is a set of pairs (a,b) where aβA and bβB, resulting from the following condition: Every element of A is paired with exactly one element of B. We write XY to denote the set of all assignments from X to Y.
example.
Let A={vanilla,chocolate,strawberry}.
Let B={waffle,cake,sugar}.
Which of the following are assignments:
The set a is an assignment, since every element of A is assigned exactly one element of B.
The set b is not an assignment, since the element "vanilla" is assigned twice.
The set c is an assignment because every element of A is assigned with exactly one element of B.
The set d is not an assignment, because not every element of A is assigned with exactly one element of B.
An assignment is just another word for function, map, mapping, or
transformation. We use the word assignment because function carries a lot
of connotations β it conjures up mental images of input-output machines,
f(x), the rule "can't divide by zero," R, pass-by-reference vs.
pass-by-value, etc. None of these are "wrong," but they all cause unnecessary
cognitive dissonance; that's the last thing we need when we're trying to count!
The same reasons extend to the other words. Maps and mappings have specific
meanings in other areas of mathematics, and transformation is almost
exclusively used in geometry. Here, an assignment is just a set of pairs that
look like (a,b), where aβA and bβB, resulting from a very
specific rule: Every element of A must be paired with exactly one element of
B.
It's important to keep the nuances of assignments in mind to avoid common
"gotchas." To do so, we can turn the definition into a logical formula. Suppose
M is an assignment from the sets A to B. Then M is an assignment
only if the following is true:
Notice that this is a two part proposition. Let's break it down by letting a,b,c be arbitrary elements. The first part says:
[(a,b)βMβ§(a,c)βM]β[b=c].
If we have an (a,b) and an (a,c), then it better be the case that b=c. The second part of the rule says:
[aβA]βΉ[bβBβ§(a,b)βM].
Let's connect this to what we've seen so far. Given sets A and B, their Cartesian product, AΓB, contains all the possible pairs (a,b) where aβA and bβB. This means that an assignment from A to B is really just a specific set of pairs. One where every aβA is paired once.
paired(a)=1.
Notice that this is entirely focused on the set A, the set whose elements
we're pairing. It doesn't say anything about the bs, other than existence.
This leaves us with a few possibilities.
paired(b)β€1.
paired(b)=1.
paired(b)β₯1.
This leads to a few different types of assignments, to be discussed shortly.
Counting Assignments
Viewed logically, we can infer a few things. First, suppose we have two sets, A={a,b,c}, and B={x,y,z}. To count the number of possible pairs, we simply multiply the cardinality of A by the cardinality of B. This gives us 3Γ3=9 possible pairs:
Asking for the number of possible pairs is a different question from asking for the number of certain combinations of pairs. If AΓB gives us the Cartesian product, then what might be the number of possible combinations? Well, if the Cartesian product has 9 pairs, then the number of possible combinations of pairs is 29=512. Not all of those combinations, however, are assignments, per our definition. Why? Because at least one of those combinations is:
{(a,x)(b,x)β(a,y)(b,y)β(a,z)(b,z)β}.
That's a combination without any cβA at all, which violates the definition of an assignment. What we want to count is just the number of combinations where every element of A is paired. Thus, for each nβA,n can be paired with x,y, or z. This means that we have:
3Γ3Γ3=27
possible combinations of pairs.
number of possible assignments. Given the sets A and B, the number of possible assignments, A to B, denoted Anβ, is given by:
Anβ=#B#A
where #B is the number of elements in B, and #A is the number of elements in A.
Injections
When paired(bβB)β€1, then we have an injection. In other
words, an assignment C:Aβ¦B where no bβB is paired more than
once. This means that a bβB can either (1) not be paired, or (2) be
paired exactly once.
injection. Let A and B be sets. Then an assignment r:Aβ¦B is an injection if, and only if, every bβB is paired at most
once under r.
In the British tradition, injections are also called one-to-one assignments. We one from a set X, to one from a set Y.
Counting Injections
enumeration of injections. Given a set A={a1β,a2β,β¦,anβ}, and a set Y={a1β,a2ββ¦,amβ}, if nβ€m, then the number of injections from X to Y is:
(mβn)!(m)(mβ1)(mβ2)β¦(mβn+1)!β.
If m<n, then there are no injections from X to Y.
Surjection
When paired(bβB)β₯1, then we have a surjection. I.e., an
assignment C:Aβ¦B where no bβB is left unpaired.
surjection. Let A and B be sets. Then an assignment r:Aβ¦B is a surjection if, and only if, every bβB is paired
at least once under r.
Surjections are also called onto assignments.
Bijection
A bijective assignment is one where every element of B is paired exactly once β paired(bβB)=1. That is, no elements are paired more than once, and no elements are left unpaired.
bijection. Let A and B be sets. Then an assignment r:Aβ¦B is a bijection if, and only if, r is both an injection and a
surjection.
Counting Bijections
enumeration of bijections. Let A and B be sets, both of cardinality n. Then there are n! bijections from X to Y.
The Truth Behind Counting
We went through the ordeal of defining assignments because there's a small fact that isn't emphasized very often in counting: Counting, fundamentally, is the act of assigning β more specifically, bijections β from the nonzero natural numbers to objects: 1 fish, 2 fish, (3, fish), (4, fish), (5, fish) β¦.
Counting Elements
The most basic form of counting is to simply count the elements of a set.
These rules provide the underlying foundation for subsequent rules.
Sum Rule
addition rule.
Let A and B be countable, disjoint sets. Then #(AβͺB)=#(AβB)=#(A)+#(B).
The theorem above provides that the cardinality of the disjoin union of sets A and B is simply the cardinality of A plus the cardinality of B.
For example, given A={a,b,c} and B={w,x,y,z}, we have AβB={a,b,c,w,x,y,z}. Thus, #(AβͺB)=#(AβB)=7.
The disjoint union is equivalent to the symmetric difference of A and B:
Aβ³B=AβB=AβͺB
Note that when we say addition rule, we are referring specifically to the addition rule of disjoint sets. The sum rule is as follows:
sum rule. Let A1β,β¦,Anβ be pairwise disjoint finite sets. Then
The product rule tells us that if an event can occur in n ways, and a second event can occur independently in k ways, then the two events can occur in nk ways.
cardinality of cartesian product. Let S1β,S2β,β¦,Skβ be finite sets with #Siβ=niβ given 1β€iβ€k. Then
example.
A license plate consists of a digit followed by three uppercase letters, followed by four digits. How many possible plates? Here, a license plate is just a tuple from the Cartesian product:
S=DΓLΓLΓLΓDΓDΓD
where D={0,1,2,β¦,8,9}, and S={A,B,C,D,β¦,Z.} Thus, there are:
#S=10Γ26Γ26Γ26Γ10Γ10Γ10=175Β 760Β 000
possible plates.
product rule. Let S be a set. If there exists a bijection
example. A fraternity name is a sequence of 2 or 3 uppercase Greek letters. How many possible names are there? There are 24 Greek uppercase letters. In the case of a 2-letter name, we have 24 choices for the first, and 24 choices for the second. In the case of a 3-letter name, we have 24 choices for the first, 24 choices for the second, and 24 choices for the third. It follows that there are: 242+243=14Β 400 possible names.
For many applications, it's also helpful to think of the product rule in terms of types: Given a set of objects, if the objects can be seperated into j types, and each of those j types can be seperated into k different subtypes, then there are jβ k different types.
Lists
A list is the most basic ordered collection. Some authors call them tuples, but we avoid using that term because in these notes, tuples are primitive objects, specifically nested sets, that exist independently of the natural numbers. I.e., tuples aren't "ordered" in the sense we're used to β there is no "first" or "second" in a tuple, because the natural numbers don't exist for them. See Set Theory Notes: Tuples. Accordingly, we use the term lists, since those can be created after constructing the natural numbers.
list. Let A be a finite set. Then a list is a finite sequence L=[a1β,a2β,a3β,β¦,anβ] where each aiββA and nβ₯0. We say that n is the length of L, and that two lists [a1β,β¦,anβ] and [b1β,β¦,bmβ] are equal if, and only if, n=m and aiβ=biβ for each 1β€iβ€k.
list enumeration. Given a set A with #A=n and a list of length k, there nk lists over A.
example.
Let A be the Latin alphabet {a,b,c,β¦,z,A,B,C,β¦,Z}. Let D be the set of digits {0,1,2,3,4,5,6,7,8,9}. How many possible strings of length 7 are there, such that: (1) The letter O never appears, (2) the first character must be a digit, and (3) the remaining five can be a digit or letter, but not O. First, there are 26 letters in the Latin alphabet, each letter uppercase or lowercase. Because the string cannot contain the letter O, we have 25Γ2=50 possible letters. The first must be a digit, of which there are 10. For each choice of the first, we have 50 choices for the second. Then we have 10+50=60 choices for the third, 60 choices for the fourth, 60 choices for the fifth, 60 choices for the sixth, and 60 choices for the seventh. This gives us: 10β 50β 605=388Β 800Β 000Β 000 possible strings.
example. How many three-digit positive integers are not multiples of 7? We first set the count's bounds. The smallest three-digit positive integer is 100. The largest three-digit positive integer is 999. We can find the smallest three digit multiple of seven by playing around with the integer quotient: β100/7β=104. 7 does not divide 103, so the smallest three-digit multiple of seven is 105=7β 15. We can get the largest three-digit multiple of seven by multiplying 10:105β 10=1050. This is out of range, so we subtract forty-nine: 1050β49=1001. This is still out of range, so we subtract seven: 1001β7=994. Thus, the largest three-digit multiple of 7 is 994. So, our count must exclude 105,112,119,β¦,994. Dividing each of these by 7, we get 15,16,17,β¦,142. Thus, there are (142β15)+1=128 multiples of 7 from 100 to 999. Since there are (999β100)+1=900 three-digit numbers, subtracting the multiples of seven gives us: 900β128=772 three-digit integers that are not multiples of 7.
example. A diplomatic meeting consists of 4 American diplomats and 3 Chinese diplomats. In how many ways can they be seated in a row of 7 chairs, such that at least 2 American diplomats are next to each other? Because there are 7 diplomats total, there are 7!=5040 possible arrangements. There is only one sequence to avoid: (a,c,a,c,a,c,a), where a is an American diplomat and c is a Chinese diplomat. If the diplomats are seated in this bad sequence, then there are 4! seatings for the Americans, and 3! seatings for the Chinese. Thus, we have 4!β 3!=144. ways to construct the bad sequence. It follows that there are 5040β144=4896 ways to seat the diplomats in a row of 7 chairs, such that at least 2 American diplomats are next to each other.
example. Let N be the set of all 3-digit natural numbers with exactly one zero. What is #N?
Consider how we construct 3-digit integers. The first digit can't be 0. So, we have 9 choices for the first. Now we have two more digits. We need exactly one zero, so it doesn't matter if it goes in the first or last, as long as the other place is not a 0. So, we have 9β 9β 2=162=#N.
example.
How many lists of the form [x1β,x2β,x3β,β¦,x7β]
can be formed where: all xiβ are integers with 0<xiβ<6 and no two adjacent xiβ are equal.
Once more, we construct. The interval tells us that we only have a set of 5 integers to work with. We have 5 choices for the first number. Then we have 4 choices for the second. We also have 4 choices for the third, since the requirement is placed on adjacency. Thus, we have: 5β 46=20Β 480 possible sequences.
example.
Let A be a non-empty set and let B be a non-empty set.
How many 8-arrangements comprising 3 elements of A and 5 elements of B if the first and last must be an element of A?
First, suppose a0β and a1β denote the two on the ends:
(a,β ,β ,β ,β ,β ,β ,a).
There are 3 choices of an A element for the first, followed by 2 choices of an A element for the last: 3β 2=6. This leaves us 6 elements to permute, so we have: 6β 6!=4320 possible 8-arrangements.
example.
Let S be a set with n(S)=4.
Let D be a set with n(D)=3.
Given sβS and dβS, how many 7-arrangements
are there such that all three d are adjacent?
Here, it's helpful to construct a few arrangements:
First, there are 3! ways to arrange the d themselves. Thus, we have 6 possible arrangements for each of the arrangements above. Then there are 4! possible arrangements for the remaining s. Thus, we have 3!β 4!=144 possible arrangements per arrangement: 144β 5=720 possible arrangements.
example. How many multiples of three are between 62 and 215? There are 51. First, we determine the smallest and largest multiple. We do so by testing the ends:
362β=2032βΒ Β Β Β Β Β Β Β 3215β=7132β.
The smallest multiple is 21Γ3=63, and the largest multiple is 71Γ2=213. Thus, we have the subsequence
(63,66,69,β¦,213).
Dividing every term by 3, we get:
3(63,66,69,β¦,213)β=21,22,23,β¦,71.
That's a sequence we know how to count: 71β21+1=51.
Permutations
A permutation has a very specific meaning in mathematics:
permutation. Let S be a set. Then a permutationp of S is a list where each element of S appears exactly once. That is, a bijection p:[n]β£S.
permutation enumeration.
Given #S=n, there are n! permutations over S.
example.
Let A be a set with #A=6.
Let B be a set with #B=4.
Let C be a set with #C=3.
Let D be a set with #D=7.
How many possible sets are there, comprising of one element of A, one element of B, one element of C, and one element of D?
We have 6 choices from A, and for each of those choices, 4 choices from B, and for each of those choices, 3 choices from C, and for each of those choices, 7 choices from D. Therefore, we have: 6β 4β 3β 7=504 possible sets.
example.
Let A be a set with #4.
How many ways are there to arrange all 4 elements?
We have 4 choices for the first. But once we've placed an element.
We have 3 choices for the second, since we've already places one element.
Then we have 2 choices for the third.
Then 1 choice for the last.
Hence, there are 4β 3β 2β 1=24 possible arrangements.
example.
Let #S=20.
How many possible triples (a,b,c) are there,
such that a,b,cβS, with aξ =bξ =c?
There are 20 choices for a, 19 choices for b, and 18 choices for c.
Thus, we have 20β 19β 18=6840 possible triples.
example. Let S={d,o,g}. How many permutations of S elements are there? There are 3!=6 arrangements.
example. Let S={b,a,l,l}. How many permutations of S are there? If we simply computed 4!=24, we would overcount. Consider the set of all such arrangements:
Because the ball appears exactly twice, we must divide by 2. There are 4!/2!=12 possible permutations. The trick is to pretend that every element is different. Since every element is different, there 2! ways where ball occurs.
example. Let S={t,a,t,t,e,r}. How many permutations of S elements are there? Once more, we want to avoid overcounting. Because there t is duplicated twice, there are 3! permutations that result in tatter. Thus, we again must divide: 6!/3!=120 permutations.
example. Let S={p,a,p,a}. How many permutations? Once more, we must correct for overcounting: 4!/(2!β 2!)=6 permutations. Because there are 2 ps, there are 2! ways for p to repeat. And for each of those ways, there are 2! ways for a to repeat.
Partial Permutations
partial permutation. Let S be a set. Then a partial permutationV of S is a list of a given length k consisting of k distinct elements of S.
partial permutation enumeration. Let S be a set with #S=n. Then the number of k-permutations of length 0β€kβ€n is
P(n,k)=(nβk)!n!β=n(nβ1)β¦(nβk+1).
Here's another formulation of this definition:
partial permutation enumeration. Let S be a set with n objects, and L be a list with k ordered slots. Then there are
(nβk)!n!β=n(nβ1)(nβ2)β¦(nβk+1)
ways to fill the k slots.
example.
Let C be a set with #C=n and nβZ+.
Let D be a set with #D=r and rβ€n.
How many injective assignments are there from C to D?
There are nβ0 choices for the first, nβ1 choices for the second,
nβ2 choices for the third, β¦,nβ(rβ1)=nβ(r+1) choices for the last.
The example above is what we call an variation β a bijection from a set S to some strict subset of S.
Consider the expression P(n,k)β P(nβk,j) where n,k,jβZ with kβ€n and jβ€nβk. With a little algebra, we can reduce this expression:
This is the formula for the number of permutations of size k, given a set of n objects, multiplied by the number of permutations of size j given nβk objects.
example.
Let A be the set {1,2,3,4,β¦,23,24,25} with #A=25.
Suppose 4 elements are drawn to construct an arrangement (a,b,c,d). First, how many possible arrangements are there if each element is excluded from A after drawing? Second, how many possible arrangements are there if each element is not excluded from A after drawing?
The first part of this question imposes a bijection requirement: There are 25 choices for the first, 24 for the second, 23 for the third, and 22 for the fourth. This gives us:
25Γ24Γ23Γ22=303Β 600
possible arrangements. The second question throws the bijection requirement out. Now we have 254=390Β 625 possible arrangements. Notice that the parameters are different for the two questions. In elementary terms, the first question does not permit "replacement" (i.e., a bijection). The second question does (no bijection requirement).
example. An alphabet Ξ£ comprises 5 letters. Every valid string over
Ξ£ has no more than 3 letters, but letters may be used more than once.
How many possible strings are there? We can have 5 letters for the first, 5
letters for the second, and 5 letters for the third: 5β 5β 5=125
strings. That's a 3 letter string. We can also have a 2 letter string: 5Γ5=25. And we can also have a 1 letter string: 5. Thus, we have
125+25+5=155 possible strings over Ξ£.
example. How many pairs of (m,n) with m,nβZ+ satisfy the
relation m2+n<22? Since m,nβZ+, it must be the case that
0<m2<22. The only perfect squares between 0 and 22 are
1,2,3,4. If m=1, then n<22β1=21. So, there are 20
possible pairs when m=1. If m=2, then n<22β4=18. There
are 17 possible pairs when m=2. If m=3, then n<22β9=13,
so 12 pairs. If m=4, then n<22β16=6. There are 5 possible
pairs. Hence, we have 21+18+13+16=54 possible pairs.
How many squares of any size can we form by connecting the dots? With 4 dots, we can make 1 square. With 6, we can make 2. With 8, we can make 3. With 10, we can make 4. This would comprise the first row, and there are 4 rows remaining. So, at a minimum, we have 4β 4=16 squares. Those are 1Γ1 squares. We can also have 2Γ2 squares. That would give us 9 total. So, we now have 25 possible squares. We can also have a 3Γ3 square, of which there are 4 possibilities. Now we're up to 29 squares. Then, there's the 4Γ4 square, which is the whole square itself. This gives us 30 possible squares. We are, however, missing a case: Squares that are rotated. I.e., those squares whose sides are not parallel to the grid. Since a square's side lengths are all equal, we can determine the square's side lengths in terms of their diagonals, which, as Pythagoras tells us, is a2+b2β.
a
b
side
number of squares
1
1
2β
9
1
2
5β
8
1
3
10β
1
2
2
8β
2
Therefore, there are 50 possible squares.
Combinations
example. A round-robin tournament consists of each player playing every other player exactly once. How many matches are held during an 8-person round-robin tennis tournament? This is a good example of a question that seems as if ordering matters, but really boils down to a combination.
example. Let S be a set with #(C)=3. Let P be a set with
#(P)=4. How many many (s,p) are there, where sβP and pβP? This is nothing more than the cardinality of the Cartesian product CΓB. Thus, there are 3Γ4=12 pairs of (s,p).
As simple as this example is, it generalizes many common counting problems. For
example, given 3 interns and 10 managers, how many possible pairings are there?
The first intern can be paired with any of the 10 managers, the second intern
can be paired with any of the 10 managers, and the third intern can be paired
with any of the 10 managers. This gives us 3Γ10=30 possible
pairings.
example.
Let A be the set A={a,b,c}.
How many possible ways are there to combine a,b, and c?
There are 8 possible ways: β ,{a},{b},{c},{a,b},{b,c},{a,c},{a,b,c}.
Given some non-empty set A, we often want to ask: How many possible combinations of A's elements are there? For example, given a set A={salty,sweet,sour}, how many possible ways are there to combine the elements?
To generate a combination C, for each element aβA, either aβC or aβ/C. This means means we have two possibilities for the first element, two possibilities for the second, two possibilities for the third, and so on. Thus, we have: 2n, where n is the number of elements of the set in question. Thus, we have:
salty
sweet
sour
combination
0
0
0
β
1
0
0
{salty}
0
1
0
{sweet}
0
0
1
{sour}
1
1
0
{salty,sweet}
0
1
1
{sweet,sour}
1
0
1
{salty,sour}
1
1
1
{salty,sweet,sour}
Notice that this gives us exactly 23=8 possible combinations. In effect, counting the number of combinations of a given set A corresponds to the number of subsets of A, that is, how many subsets are in the power set of A?
number of subsets. Let S be a set. Then the number of subsets of S is 2β£Sβ£, where β£Sβ£ is the cardinality of S.
example. 4 candidates run for President and Vice President. How many possible pairs of (President, Vice President) (assuming no person can be both)? There are 4 choices for President. After we pick one, there are 3 choices for the second: 12 possible pairs.
Binomial Coefficients
example. How many ways can 2-seat committee be chosen from a group of 4 people (order of choosing irrelevant)?
Start with a simple set: {a,b,c,d}, enumerating all possible sets:
Notice the duplicates in red. There are 6 possible ways.
example. In how many ways can three seats {a,b,c} be taken given a group of 8 people?
Again, if we simply permuted β (8)(7)(6)=210 β we'd get an overcount.
We know that the first permutation causes an overcount of 1. The second permutation causes an overcount of 2. The third permutation causes an overcount of 3. Thus, we have (8β 7β 6)/(1β 2β 3)=56 ways.
Determining the maximum number of combinations is so widespread in mathematics that we have special notation for it. The last example can be expressed with any of the following expressions:
Each of the expressions above is read as "8 choose 3" or "8 pick 3." Is there a general formula for this computation? Recall that a permutation tells us how many ways we can arrange objects in order. Given n objects, we have n choices for index one, nβ1 objects for index two, nβ2 objects for index 3, all the way down to nβ(rβ1). At each count, we pair an element with every other element. This results in r! duplicates, which means that we have:
r!n(nβ1)(nβ2)β¦(nβ(rβ1))β.
The numerator of this expression can be expressed another way:
That final expression is called the binomial coefficient.
binomial coefficient. Given kβN and nβN with 0β€kβ€n, the binomial coefficient of n and k is
(knβ)=C(n,k)=k!(nβk)!n!β,
which we read as "n choose k." If k<0 or k>n, then we define (knβ)=C(n,k)=0. For all nβ₯0 and all k,(knβ) is the number of k-element subsets of an n-element set.
example. In a state lottery, 48 balls are numbered 1 to 48, and 6 are chosen. How many different sets of winning numbers are there? This is a classic combination problem. We a set of 48, and we're asked to count how many subsets of size 6 we can make. So, we have (648β)=48!/(6!)=12Β 271Β 512. As we can see, the odds of winning a state lottery β assuming all outcomes are equally likely β is very, very low.
Bitstrings
Consider the set of all binary digits, B={0,1}, and a set S={a,b,c}. One way we can count all of the possible subsets of S is to establish a bijection f:Sβ£B3. The product B3 gives us the following strings:
{000110β100101β010011β001111β}.
Now, we can count all of the possible subsets of S mapping each element of S to each string of B3. These mappings are displayed in the table below, where each β‘ represents an empty position.
string
000
β‘Β β‘Β β‘
β
100
aΒ β‘Β β‘
a
010
β‘Β bΒ β‘
b
001
β‘Β cΒ β‘
c
110
β‘aΒ b
ab
101
aΒ β‘Β c
ac
011
β‘Β bΒ c
bc
111
aΒ bΒ c
abc
This simply confirms that the number of possible subsets of a given set S
is 2n, where n is the cardinality of S.
Compositions
Because the naturals are defined as sets, given two naturals n and m with m<n, we can break down n into its elements (other naturals less than or equal to n). Thus, the sequence (1,1,1,1) is another way to represent 4, and so is (1,3), and so is (2,2), as well as (1,1,2), etc. Each of these sequences is called a composition of 4.
composition. Given an integer n, a composition of n is a sequence t=t1β,t2β,β¦,tkβ, where each tiβ is a positive integer and βi=1kβtiβ=t1β+t2β+β¦+tkβ=n, with kβZ+ corresponding to the number of parts of t. We write comp[n] to denote the set of all compositions of n.
composition count. For all integers n>0, there are 2nβ1 compositions of n.
Anagrams
What do βsilverβ,βsliverβ,βliversβ, and βieslrvβ have in common? They consist entirely of the same elements. Each of these strings are anagrams of one another. The integer 172 has the anagrams 127, 712,721,217, and 271.
anagram. Let {a1β,a2β,β¦,akβ} be a list of distinct elements n1β,n2β,β¦,nkβ be natural numbers. An anagram is a list w=(w1β,w2β,β¦,wnβ) formed by rearranging n1β copies of a1β,n2β copies of a2β,β¦,nkβ copies of akβ, such that n=n1β+n2β+β¦nkβ. We denote the set of all anagrams of a given list w with the notation anagram(a1n1ββ,a2n2ββ,a3n3ββ,β¦,aknkββ).
If we think about how an anagram is generated, this is simply a binomial coefficient. There are n! ways for the first position, (nβ1)! factorials for the second, (nβ2)! for the third, and so on, where n=n1β+n2β+n3β+β¦+nkβ. As we saw with the binomial coefficient, we then correct for the overcount. Thus, we have:
In short, they're dots marking the vertices
along a path, where, at each vertex, we can only move
right by 1, or up by 1. It's likely not apparent, but
these paths are closely related to binomial coefficients.
lattice path. A lattice path is a sequence P=((x0β,y0),(x1β,y1β),β¦,(xkβ,ykβ)), where each xiβ and yiβ is an integer, such that (xiβ,yiβ)=(xiβ1β+1,yiβ1β), or (xiβ,yiβ)=(xiβ1β,yiβ1β+1), for all iβN:iβ₯1.
While lattice diagrams are helpful, it's often easier to express them as words. If we start at some point (a,b) we can denote the path to some other point (c,d) with the letters N (north) and E (east). For example, if we start at the bottom-left point for the the lattice path:
βββββββββββββββ
we may denote it as: NNENE. Viewed this way, we can see that this is an alphabet with two letters. If we want a lattice path from (0,0) to (a,b), we need a of the E steps and b of the N step. Which in turn means that there, at most, (a,ba+bβ) lattice paths to get from (0,0) to (a,b).