Wednesday, December 28, 2011

Permutations without Repetition


2. Permutations without Repetition

In this case, you have to reduce the number of available choices each time.
For example, what order could 16 pool balls be in?
After choosing, say, number "14" you can't choose it again.
So, your first choice would have 16 possibilites, and your next choice would then have 15 possibilities, then 14, 13, etc. And the total permutations would be:
16 × 15 × 14 × 13 × ... = 20,922,789,888,000
But maybe you don't want to choose them all, just 3 of them, so that would be only:
16 × 15 × 14 = 3,360
In other words, there are 3,360 different ways that 3 pool balls could be selected out of 16 balls.
But how do we write that mathematically? Answer: we use the "factorial function"


So, if you wanted to select all of the billiard balls the permutations would be:
16! = 20,922,789,888,000
But if you wanted to select just 3, then you have to stop the multiplying after 14. How do you do that? There is a neat trick ... you divide by 13! ...
16 × 15 × 14 × 13 × 12 ...
 = 16 × 15 × 14 = 3,360
13 × 12 ...
Do you see? 16! / 13! = 16 × 15 × 14
The formula is written:
where n is the number of things to choose from, and you choose r of them
(No repetition, order matters)

Examples:

Our "order of 3 out of 16 pool balls example" would be:
16!=16!=20,922,789,888,000= 3,360
(16-3)!13!6,227,020,800
(which is just the same as: 16 × 15 × 14 = 3,360)
How many ways can first and second place be awarded to 10 people?
10!=10!=3,628,800= 90
(10-2)!8!40,320
(which is just the same as: 10 × 9 = 90)

Permutations with Repetition


1. Permutations with Repetition

These are the easiest to calculate.
When you have n things to choose from ... you have n choices each time!
When choosing r of them, the permutations are:
n × n × ... (r times)
(In other words, there are n possibilities for the first choice, THEN there are n possibilites for the second choice, and so on, multplying each time.)
Which is easier to write down using an exponent of r:
n × n × ... (r times) = nr
Example: in the lock above, there are 10 numbers to choose from (0,1,..9) and you choose 3 of them:
10 × 10 × ... (3 times) = 103 = 1,000 permutations
So, the formula is simply:
nr
where n is the number of things to choose from, and you choose r of them
(Repetition allowed, order matters)

Tuesday, December 27, 2011

Combinations with Repetition


1. Combinations with Repetition

OK, now we can tackle this one ...
Let us say there are five flavors of icecream: banana, chocolate, lemon, strawberry and vanilla. You can have three scoops. How many variations will there be?
Let's use letters for the flavors: {b, c, l, s, v}. Example selections would be
  • {c, c, c} (3 scoops of chocolate)
  • {b, l, v} (one each of banana, lemon and vanilla)
  • {b, v, v} (one of banana, two of vanilla)
(And just to be clear: There are n=5 things to choose from, and you choose r=3 of them.
Order does not matter, and you can repeat!)
Now, I can't describe directly to you how to calculate this, but I can show you a special technique that lets you work it out.
Think about the ice cream being in boxes, you could say "move past the first box, then take 3 scoops, then move along 3 more boxes to the end" and you will have 3 scoops of chocolate!
 So, it is like you are ordering a robot to get your ice cream, but it doesn't change anything, you still get what you want.
Now you could write this down as  (arrow means move, circle means scoop).
In fact the three examples above would be written like this:
{c, c, c} (3 scoops of chocolate):
{b, l, v} (one each of banana, lemon and vanilla):
{b, v, v} (one of banana, two of vanilla):
OK, so instead of worrying about different flavors, we have a simpler problem to solve: "how many different ways can you arrange arrows and circles"
Notice that there are always 3 circles (3 scoops of ice cream) and 4 arrows (you need to move 4 times to go from the 1st to 5th container).
So (being general here) there are r + (n-1) positions, and we want to choose r of them to have circles.
This is like saying "we have r + (n-1) pool balls and want to choose r of them". In other words it is now like the pool balls problem, but with slightly changed numbers. And you would write it like this:
where n is the number of things to choose from, and you choose r of them
(Repetition allowed, order doesn't matter)
Interestingly, we could have looked at the arrows instead of the circles, and we would have then been saying "we have r + (n-1) positions and want to choose (n-1) of them to have arrows", and the answer would be the same ...
So, what about our example, what is the answer?
(5+3-1)!=7!=5040= 35
3!(5-1)!3!×4!6×24


Tuesday, December 20, 2011

Section 7.1: Discrete Mathematics and Its Applications, Extra Examples


Rosen, Discrete Mathematics and Its Applications, 6th edition
Extra Examples
Section 7.1—Recurrence Relations

p.451, icon at Example 3
#1. Find a recurrence relation (and initial condition) for each of the following:
(a) the number of strings of length n of letters of the alphabet.
(b) the number of strings of length n of letters of the alphabet, if no adjacent letters can be the same.
(c) the number of strings of length n of letters of the alphabet with no repeated letters.
Solution:
(a) Let an equal the number of strings of length n of letters of the alphabet. We can obtain any such string
by taking a string s of length n − 1 and appending a letter to the end of s. This can be done in 26 ways.
Therefore, an = 26an−1. The initial condition is a1 = 26.
(b) Let bn equal the number of strings of length n of letters of the alphabet with no adjacent letters identical.
Each such string can be obtained from a string s of length n − 1 by taking s and appending to it a letter
that is different from the last letter of s. Because there are 25 letters that can be appended, there are 25
ways to extend s to a string of length n. Therefore, bn = 25bn−1. The initial condition is b1 = 26.
(c) Let cn equal the number of strings of length n of letters of the alphabet with no repeated letters. Each
such string can be obtained from a string s of length n − 1 by taking s and appending to it a letter that is
different from each of the letters of s. Because there are n−1 letters used in s, there are 26−(n−1) = 27−n
letters available to be appended to s. Therefore, cn = (27 − n)cn−1. The initial condition is c1 = 26. Note
that c27 = (27 − 27)c26 = 0 because there are only 26 letters in the alphabet. Likewise, the recurrence
relation yields c28 = c29 = . . . = 0.

p.451, icon at Example 3
#3. Suppose bn = 2bn−1 + n − 2n and b0 = 5.
(a) Find bn−1 in terms of bn−2.
(b) Find bn in terms of bn−2.
(c) Find bn in terms of bn−3.
(d) Use parts (b) and (c) to conjecture a formula for bn.
Solution:
(a) The recurrence relation for bn doubles the previous term (which is 2bn−1), adds the subscript number of
bn (which is n), and subtracts 2 raised to the power of the subscript of bn (which is 2n).
The term bn−1 is obtained in the same way: double the previous term (which is 2bn−2), add the subscript
number of bn−1 (which is n−1), and subtract 2 raised to the power of the subscript of bn−1 (which is 2n−1).
Therefore bn−1 = 2bn−2 + (n − 1) − 2n−1.
(b) To obtain bn in terms of bn−2, we first use the recurrence relation to obtain bn in terms of bn−1 and then
use part (a) to obtain bn−1 in terms of bn−2:
bn = 2bn−1 + n − 2n
= 2[2bn−2 + (n − 1) − 2n−1] + n − 2n
= 22bn−2 + (n − 1) + n − 2n−1 − 2n.
(c) To obtain bn in terms of bn−3, we can use the recurrence equation for bn−2 and part (b). The recurrence
relation for bn−2 is bn−2 = 2bn−3 +(n−2)−2n−2. Substituting for bn−2 into the result in part (b), we have
bn = 22bn−2 + (n − 1) + n − 2n−1 − 2n
= 22[2bn−3 + (n − 2) − 2n−2] + (n − 1) + n − 2n−1 − 2n
= 23bn−3 + (n − 2) + (n − 1) + n − 2n−2 − 2n−1 − 2n.
(d) Mentally continuing the pattern in part (c), it seems reasonable to guess that the first term becomes
2nb0, the sum (n−2)+(n−1)+n becomes 1+2+3+· · ·+(n−2)+(n−1)+n, and the sum of the powers
of 2 being subtracted becomes −21 − 22 − 23 −· · ·−2n−1 − 2n−1 − 2n. Thus, it is reasonable to conjecture
that
bn = 2nb0 + [1 + 2 + 3 + · · · + (n − 2) + (n − 1) + n] − [21 + 22 + 23 + · · ·+ 2n−1 + 2n−1 + 2n]
= 5· 2n + n(n + 1)
2
− 2n+1,
2
where summation formulas were used at the last step to replace 1 + 2 + 3 + · · · + (n − 2) + (n − 1) + n and
21 + 22 + 23 + · · ·+ 2n−1 + 2n−1 + 2n.
Note: You can check that this is correct by substituting the formula for bn and bn−1 into the given recurrence
relation and showing that both sides of the recurrence relation are equal.


p.451, icon at Example 3
#4. Solve: an = 3an−1 + 1, a0 = 4, by substituting for an−1, then an−2, etc.
Solution:
Beginning with an = 3an−1 + 1 and substituting for an−1, then an−2, then an−3, etc., yields:
an = 3an−1 + 1
= 3(3an−2 + 1)+ 1
= 32an−2 + 3 · 1 + 1
= 32(3an−3 + 1) + 3 · 1 + 1
= 33an−3 + 32 · 1 + 3 · 1 + 1
...
= 3na0 + (3n−1 + 3n−2 + · · ·+ 32 + 3 + 1)
= 4· 3n +
3n − 1
2
=
9
2
· 3n − 1
2
=
3n+2
2
− 1

p.451, icon at Example 3
#5. Find a formula for the recurrence relation an = 2an−1 + 2n, a0 = 1, using a recursive method.
Solution:
an = 2an−1 + 2n
= 2(2an−2 + 2n−1) + 2n = (22an−2 + 2·2n−1) + 2n = (22an−2 + 2n) + 2n = 22an−2 + 2·2n
= 22(2an−3 + 2n−2) + 2·2n = (23an−3 + 22·2n−2) + 2·2n = (23an−3 + 2n) + 2·2n = 23an−2 + 3·2n.
At this stage it would be reasonable to guess that if we continue this process we will obtain:
an = 2na0 + n · 2n = 2n · 1 + n · 2n = (n + 1)2n.
Therefore, an = (n + 1)2n is a formula for the given sequence.
We can verify that this formula is correct by substituting an = (n+1)2n and an−1 = n2n−1 into the original
recurrence relation and checking that an equality results.:
2an−1 + 2n = 2(n2n−1) + 2n = n2n + 2n = (n + 1)2n = an.


p.451, icon at Example 3
#6. You begin with $1000. You invest it at 5% compounded annually, but at the end of each year you
withdraw $100 immediately after the interest is paid.
(a) Set up a recurrence relation and initial condition for the amount you have after n years.
(b) How much is left in the account after you have withdrawn $100 at the end of the third year?
(c) Find a formula for an.
(d) Use the formula to determine how long it takes before the last withdrawal reduces the balance in
the account to $0.
Solution:
(a) For n > 0, let an be the amount in the account at the end of year n; i.e., just after the interest has been
added to the account and the $100 has been withdrawn. Then an is equal to the amount from the previous
year (an−1) plus the interest earned (0.05an−1) minus the $100 withdrawal. That is,
an = an−1 + 0.05an−1 − 100 = 1.05an−1 − 100, if n > 0, a0 = 1000.
(b) Using the recurrence relation yields
a1 = 1050 − 100 = 950
a2 = 1.05a1 − 100 = 1.05(950)− 100 = 997.50 − 100 = 897.50
a3 = 1.05a2 − 100 = 1.05(897.50)− 100 = 942.38 − 100 = 842.38
Thus, the answer is $842.38.
(c) To develop a formula, note that
an = 1.05an−1 − 100,
an−1 = 1.05an−2 − 100,
an−2 = 1.05an−3 − 100,
...
Therefore
an = 1.05an−1 − 100
= 1.05(1.05an−2 − 100) − 100
= 1.052an−2 − (1.05·100) − 100
= 1.052(1.05an−3 − 100) − (1.05·100) − 100
= 1.053an−3 − (1.052·100) − (1.05·100) − 100
...
= 1.05na0 − (1.05n−1·100) − (1.05n−2·100)−· · ·−(1.052·100) − (1.05·100) − 100
= 1.05n·1000 − 100(1.05n−1 + 1.05n−2 + · · ·+ 1.052 + 1.05 + 1)
= 1.05n·1000 − 100 · 1.05n − 1
1.05 − 1
= 1.05n·1000 − 2000(1.05n − 1)
= 2000 − 1.05n·1000
and hence a formula for an is an = 2000 − 1.05n · 1000.
(d) Using various values of n in the formula for an yields a14 = 20.07 and a15 = −78.93. Hence, at the
end of the 15th year the balance will be 1.05 · 20.07 = 21.07 before a withdrawal is made; if this amount is
withdrawn, the balance will become $0. (Alternately, we could solve the equation 2000 − 1.05n · 1000 = 0
for n and obtain n as the solution.)


p.451, icon at Example 3
#7. Find a recurrence relation for the number of strings of letters of the ordinary alphabet that do not
have adjacent vowels.
Solution:
Let us call a string of letters of the alphabet “good” if it has no adjacent vowels. Let an be the number of
strings of length n of letters of the alphabet that do not have adjacent vowels.
The set of all good strings of length n is the union of the following two disjoint sets —
A: the set of good strings of length n that end with a consonant, and
B: the set of good strings of length n that end with a vowel.
Each string in A can be obtained from a good string of length n − 1 by adding any consonant at the end of
the string. Thus, |A| = 21 · an−1.
Each string in B ends with a vowel. In this case we know that that second letter from the end must be
a consonant (otherwise the string would have adjacent vowels). Thus, each string in B is a good string
of length n − 2 followed by a consonant (in the second last position) and a vowel at the end. Therefore,
|B| = 5· 21 · an−2.
Because A and B are disjoint, the set of all good strings of length n is their sum, |A| + |B|. That is,
an = 21an−1 + 105 an−2.
The two initial conditions are obtained by counting the number of good strings of lengths 1 and 2: a1 = 26
because any string of one of the 26 letters of the alphabet cannot have adjacent vowels; a2 = 262 −52 = 651
(we take all strings of length 2 and subtract those with two vowels).


p.451, icon at Example 3
#8. You have two distinct parallel lines L1 and L2. You keep adding additional lines, L3, L4, . . ., with
none parallel to L1 or L2 or to each other, and no three passing through the same point.
(a) Find a recurrence relation and initial condition(s) for rn, which is defined to be the number of regions
into which the plane is divided by the lines L1, L2, . . ., Ln.
(b) Find a formula for the number of regions into which the plane is divided by L1, L2, . . ., Ln.
Solution:
(a) The recurrence relation is rn = rn−1 + n (n > 2), with initial condition r2 = 3. To see this, note that
line Ln must cut each of the previous n − 1 lines in exactly one point. This in effect divides Ln into n
segments, each of which divides an existing region into two parts. Therefore, rn = rn−1 + n.
(b) Proceeding inductively:
r2 = 3,
r3 = r2 + 3 = 3 + 3,
r4 = r3 + 4 = 3 + 3 + 4,
r5 = r4 + 5 = 3 + 3 + 4 + 5,
r6 = r5 + 6 = 3 + 3 + 4 + 5 + 6.
This suggests that
rn = 3 + (3 + 4 + · · · + n)
= (1 + 2) + (3 + 4 + · · · + n)
= 1 + 2 + 3 + · · · + n
= n(n + 1)
2 .
To verify that this guess is correct, take rn = rn−1 + n and substitute n(n + 1)
2
for rn and
(n − 1)n
2
for
rn−1, obtaining n(n + 1)
2
=
(n − 1)n
2
+n, which is true because the right side simplifies to give the left side:
(n − 1)n
2
+ n =
(n − 1)n + 2n
2
= n2 + n
2
= n(n + 1)
2


.
p.451, icon at Example 3
#9. This is a variation on Fibonacci’s rabbit sequence. We begin with one pair of newborn rabbits. Once a
pair is two months old, the pair has two pairs of offspring, and continues to have two pairs of offspring each
month thereafter. Give a recurrence relation and initial condition(s) for the sequence fn, where fn is equal
to the number of pairs of rabbits alive at the end of the nth month (after the offspring are born). Assume
that the rabbits never die during the period being considered.
Solution:
The number of pairs at the end of n months (fn) is equal to the number of pairs alive one month earlier
(fn−1) plus the number of newborn pairs. But each pair of rabbits alive two months earlier gives birth to
two pairs of newborn rabbits. Therefore, there are 2fn−2 pairs of newborn rabbits. Hence
fn = fn−1 + 2fn−2, f(1) = 1, f(2) = 3.


p.451, icon at Example 3
#10. Here is another variation on Fibonacci’s rabbit sequence. We begin with one pair of newborn rabbits.
At the end of each month a new pair of newborn rabbits is added to the population. Once any pair is
two months old, the pair has one pair of offspring and continues to have one pair of offspring each month
thereafter. Give a recurrence relation and initial condition(s) for the sequence fn, where fn is equal to the
number of pairs of rabbits alive at the end of the nth month (after the rabbits have given birth and the
newborn pair has been introduced). Assume that the rabbits never die during the period being considered.
Solution:
The number of pairs at the end of n months (fn) is equal to 1 (the newborn pair added) plus the number
of pairs alive one month earlier (fn−1) plus the number of newborn pairs (which is equal to the number of
pairs alive two months earlier, fn−2. Thus
fn = 1+fn−1 + fn−2, f(1) = 2, f(2) = 4.


p.451, icon at Example 3
#11. Here is a third variation on Fibonacci’s rabbit sequence. We begin with one pair of newborn rabbits.
Once the pair is three months old, the pair has one pair of offspring, and continues to have one pair of offspring
every other month thereafter. Give a recurrence relation and initial condition(s) for the sequence fn, where fn
is equal to the number of pairs of rabbits alive at the end of the nth month (just after any offspring are
born). Assume that the rabbits never die during the period being considered.
Solution:
The number of pairs alive at the end of n months (fn) is equal to the number of pairs alive one month earlier
(fn−1) plus the number of pairs of newborn rabbits. To determine the number of newborn pairs, we need to
know the number of pairs born three months earlier, five months earlier, seven months earlier, etc. But, for
example, the number of pairs born three months before month n is equal to fn−3 −fn−4 and the number of
pairs born five months before month n is equal to fn−5 − fn−6.
Thus,
fn = fn−1 + number of pairs born in month n
= fn−1 + (fn−3 − fn−4) + (fn−5 − fn−6) + (fn−7 − fn−8) + · · ·
where the sum continues as long as the subscripts are positive. Similarly,
fn−1 = fn−2 + number of pairs born in month n − 1
= fn−2 + (fn−4 − fn−5) + (fn−6 − fn−7) + (fn−8 − fn−9) + · · · .
Substitute fn−1 from the second equation into the first equation. Almost all terms cancel and we obtain
fn = fn−2 + fn−3,
with f(1) = 1, f(2) = 1, f(3) = 2.



p.451, icon at Example 3
#12. (Problem A1 from the 1990 William Lowell Putnam Mathematics Competition)
Here are the first ten terms of an infinite sequence:
2, 3, 6, 14, 40, 152, 784, 5168, 40567, 363392.
(a) Find a formula for an infinite sequence a0, a1, a2, a3, . . . such that the first ten terms of the sequence are
the ones given here. (Hint: consider the sum of two rapidly increasing sequences.)
(b) Show that the sequence in (a) satisfies the recurrence relation
an = (n + 4)an−1 − 4nan−2 + (4n − 8)an−3.
Solution:
(a) The sequence increases rapidly, which suggests the possibility that the formula may involve an exponential
function cn. If we look for 2n in each term, we find the the first few terms are:
20 + 1, 21 + 1, 22 + 2, 23 + 6, 24 + 24, 25 + 120, 26 + 720, 27 + 5040 .
The second term in each sum is a factorial, yielding
20 + 0!, 21 + 1!, 22 + 2!, 23 + 3!, 24 + 4!, 25 + 5!, 26 + 6!, 27 + 7! .
Thus, an = 2n + n! is one such formula.
(b) We need to show that an = (n+4)an−1−4nan−2+(4n−8)an−3 is satisfied by the sequence an = 2n+n!.
That is,
2n + n! = (n + 4)[2n−1 + (n − 1)! ] − 4n[ 2n−2 + (n − 2)! ] + (4n − 8)[ 2n−3 + (n − 3)! ].
The right side can be simplified as follows:
(n + 4)[2n−1 + (n − 1)! ] − 4n[ 2n−2 + (n − 2)! ] + (4n − 8)[ 2n−3 + (n − 3)! ]
= n2n−1 + 4 · 2n−1 − 4n2n−2 + 4n2n−3 − 8 · 2n−3+
n(n − 1)! + 4(n − 1)! − 4n(n − 2)! + (4n − 8)(n − 3)!
= n2n−1 + 2n+1 − n2n + n2n−1 − 2n + n! + 4(n − 1)! − 4n(n − 2)! + (4n − 8)(n − 3)!
= n2n + 2n+1 − n2n − 2n + n! + 4(n − 1)! − 4n(n − 2)! + (4n − 8)(n − 3)!
= 2n+1 − 2n + n! + 4(n − 1)! − 4n(n − 2)! + (4n − 8)(n − 3)!
= 2n + n! + 4(n − 1)! − 4n(n − 2)! + (4n − 8)(n − 3)!
= 2n + n! + 4(n − 1)! − 4n(n − 2)! + 4(n − 2)!
= 2n + n! + 4(n − 1)! + (4 − 4n)(n − 2)!
= 2n + n! + 4(n − 1)! − 4(n − 1)(n − 2)!
= 2n + n! + 4(n − 1)! − 4(n − 1)!
= 2n + n!.



p.451, icon at Example 3
#13. Suppose a chess king is placed on the lower left square of an m×n chessboard (that is, a rectangular
board with m rows and n columns). Let M(m, n) be equal to the number of paths that a king can use
moving from the lower left corner to the upper right corner of an m×n board, with the restriction that each
move is either up, to the right, or diagonally up and to the right.
(a) Find a recurrence relation and initial condition(s) for M(m, n).
(b) Find the number of ways in which the king can move from the lower left square to the upper right
square on a 5 × 5 chessboard.
Solution:
(a) In order for the king to reach the upper right square, the king’s last move must be from one of the
following three squares: the square immediately below the corner square, the square immediately to the left
of the corner square, or the square diagonally down and to the left of the corner square. The number of
ways in which the king could have arrived at each of these three squares is M(m, n − 1), M(m − 1, n), and
M(m− 1, n − 1), respectively (assuming that m > 1 and n > 1). Therefore,
M(m, n) = M(m, n − 1) +M(m− 1, n) +M(m− 1, n − 1),
with initial conditions M(1, 1) = M(2, 1) = M(1, 2) = 1.
(b) First note that M(k, 1) = M(1, k) = 1 for all k > 1 and M(j, k) = M(k, j) for all j and k (by symmetry).
The following steps use the recurrence relation to find M(5, 5):
M(2, 2) = M(2, 1) +M(1, 2) +M(1,1) = 1 + 1 + 1 = 3
M(2, 3) = M(3, 2) = M(1, 3) +M(2, 2) +M(1,2) = 1 + 3 + 1 = 5
M(3, 3) = M(3, 2) +M(2, 3) +M(2,2) = 5 + 5 + 3 = 13
M(2, 4) = M(4, 2) = M(1, 4) +M(2, 3) +M(1,3) = 1 + 5 + 1 = 7
M(2, 5) = M(5, 2) = M(1, 5) +M(2, 4) +M(1,4) = 1 + 7 + 1 = 9
M(3, 4) = M(4, 3) = M(3, 3) +M(2, 4) +M(3,2) = 13 + 7 + 5 = 25
M(3, 5) = M(5, 3) = M(4, 3) +M(5, 2) +M(2,4) = 25 + 9 + 7 = 41
M(4, 4) = M(4, 3) +M(3, 4) +M(3, 3) = 25 + 25 + 13 = 63
M(4, 5) = M(5, 4) = M(4, 4) +M(3, 5) +M(3, 4) = 63 + 41 + 25 = 129
M(5, 5) = M(5, 4) +M(4, 5) +M(4, 4) = 129 + 129 + 63 = 321.
Therefore, M(5, 5) = 321.
This is shown in the following table, where, beginning from the lower left corner, each square has as its value
the sum of the numbers in the squares directly below, to the left, and diagonally below on the left.
1 9 41 129 321
1 7 25 63 129
1 5 13 25 41
1 3 5 7 9
1 1 1 1 1

Section 10.5:Discrete Mathematics and Its Applications, Extra Examples

Discrete Mathematics and Its Applications, Extra Examples
Section 10.5




p.740, icon at Example 3
#2. Suppose the vertices of Kn are numbered 1, 2, . . ., n (in clockwise order) and each edge is assigned a
weight equal to the sum of the labels on the endpoints of the edge. Find a spanning tree of minimum weight
for this graph and find the weight of this spanning tree.
Solution:
The spanning tree of minimum cost has edges {1, 2}, {1, 3}, . . ., {1, n}. Using either Kruskal’s Algorithm or
Prim’s Algorithm, the first edges added are {1, 2} and {1, 3}. At the next stage, edges {2, 3} and {1, 4}
have the smallest weight, but adding edge {2, 3} would create a circuit. Therefore edges {1, 2}, {1, 3}, and
{1, 4} are inserted into the spanning tree. In general, if edges {1, 2}, {1, 3}, . . ., {1, k} have been selected, the
next edge inserted must be {1, k + 1} (of weight k + 2). (Any other edge {i, j} with weight ≤ k + 2 would
have 1 < i ≤ k and 1 < j ≤ k and would create a circuit when combined with {1, i} and {1, j}.) Thus, the
spanning tree of minimum weight consists of {1, 2}, {1, 3}, . . . , {1, n}. Its total weight is
(1 + 2) + (1 + 3) + · · · + (1+n) = (n − 2) + n(n + 1)
2
=
(n + 4)(n − 1)
2
.

Section 10.1: Discrete Mathematics and Its Applications, Extra Examples


Rosen, Discrete Mathematics and Its Applications, 6th edition
Extra Examples
Section 10.1—Introduction to Trees


p.686, icon at Example 2
#1.
(a) Find the number of nonisomorphic rooted trees with four vertices.
(b) Find the number of nonisomorphic labeled rooted trees with four vertices. (Two trees are isomorphic as
labeled trees if they are isomorphic with vertex i in the first graph corresponding to vertex i in the second
graph.)
(c) Suppose you have four cloth bags — red, blue, green, and yellow. In how many different ways can they
be put inside each other. (For example, the red bag and the yellow bag might be put separately inside the
green bag, and this green bag might then be put inside the blue one, as in the following figure.)

Solution:
(b) The rooted tree A can be labeled in 4! ways. The rooted tree B can be labeled in 4 · 3 ways (there are
four ways to label the root and three ways to label its child; the other two vertices can be labeled in either
order without producing a different tree because the tree is not ordered). The rooted tree C can be labeled
in 4 ways (corresponding to the number of ways of labeling the root). The rooted tree D can be labeled in
4 · 3 · 2 ways (label the root, then label the child that has no descendants, and finally label the child that has
a single descendant). Therefore, the total number of labeled rooted trees is equal to
4! + 4·3 + 4 + 4·3·2 = 64.
(c) There are four patterns according to which the four bags can be placed inside each other — they
correspond to the four nonisomorphic rooted trees in part (a). (For example, the illustration in part (c)
above has the pattern of rooted tree B with “blue” as the root, “green” as its child, and “red” and “yellow”
as the children of “green”.) Therefore, using part (b) of the solution, there are 64 ways in which the bags
can be put inside one another.

Section 11.1: Discrete Mathematics and Its Applications, Extra Examples




Rosen, Discrete Mathematics and Its Applications, 6th edition
Extra Examples
Section 11.1—Boolean Functions


p.754, icon at Example 10
#1. Prove the idempotent law x = x · x using the other identities of Boolean algebra listed in Table 5 of
Section 11.1 the textbook.
Solution:
x = x ·1 identity law
= x · (x + x) unit property
= x · x + x · x distributive law
= x · x + 0 zero property
= x · x. identity law


p.754, icon at Example 10
#2. Prove the domination law x · 0 = 0 using the other identities of Boolean algebra listed in Table 5 in
Section 11.1 of the textbook.
Solution:
x ·0 = x · (x · x) zero property
= (x · x) · x associative law
= x · x idempotent law
= 0. zero property


p.754, icon at Example 10
#3. Using the properties of Boolean algebra, prove that
yz + x(xz) + y(z + 1)+zx
can be simplified to give y + zx.
Solution:
yz + x(xz) + y(z + 1) + zx = yz + x(x + z) + y(z + 1) + zx De Morgan’s law
= yz + xx + xz + yz + y + zx distributive law; identity law
= yz +0+xz + yz + y + zx zero property
= yz + xz + yz + y + zx identity law
= y + yz + yz + xz + zx commutative law
= y + y(z + z) + xz + zx distributive law
= y + y1+ xz + zx unit property
= y + y + xz + zx identity law
= y + xz + zx idempotent law= y + zx + zx commutative law
= y + zx. idempotent law


Section 12.3-Finite-State Machines with Output-Discrete Mathematics and Its Applications

Rosen, Discrete Mathematics and Its Applications, 6th edition
Extra Examples
Section 12.3— Finite-State Machines with Output

p.807, icon at Example 6
#3. Determine the set of bit strings recognized by the following deterministic finite-state automaton.

Solution:
If the bit string ends in 0, you end in state s2. If the bit string ends in 1, you end in state s1. Therefore, this automaton recognizes all bit strings that end in 0.


p.807, icon at Example 6
#4. Determine the set of bit strings recognized by the following deterministic finite-state automaton.

Solution:
If the bit string has two consecutive 0’s or two consecutive 1’s, you end in state s3. If the bit string has no two consecutive 0’s or two consecutive 1’s, you end in either state s1 or s2. Therefore, this automaton recognizes all bit strings that alternate 0’s and 1’s.


p.807, icon at Example 6
#5. Determine the set of bit strings recognized by the following deterministic finite-state automaton.

Solution:
The string must end in 01 in order to be recognized by this automaton. If the string ends in 11, the string ends in state s0. If the string ends in 0, the string ends in state s1.

Section 12.1: Modeling Computation- Discrete Mathematics and Its Applications

Rosen, Discrete Mathematics and Its Applications, 6th edition
Extra Examples
Section 12.1—Modeling Computation

#1. Let G = (V, T, S,P) be a grammar where V = {S, A,B, a, b} is the vocabulary and T = {a, b} is the set of terminal elements. Determine whether the following set of productions is a:
(i) a type 0 grammar, but not a type 1 grammar.
(ii) a type 1 grammar, but not a type 2 grammar.
(iii) a type 2 grammar, but not a type 3 grammar.
S → ABA, A → bB, B → ba.

Solution:

It is a type 2 grammar because the left side of each production has a single nonterminal symbol. It is not a type 3 grammar because of the form of the right side of the third production.


p.790, icon at Example 8
#2. Let G = (V, T, S,P) be a grammar where V = {S, A,B, a, b} is the vocabulary and T = {a, b} is the set of terminal elements. Determine whether the following set of productions is a:

(i) a type 0 grammar, but not a type 1 grammar.
(ii) a type 1 grammar, but not a type 2 grammar.
(iii) a type 2 grammar, but not a type 3 grammar.
S → AB, B → bAa, bAa → a.

Solution:
It is automatically a type 0 grammar. It is not a type 1 grammar because the third production is not noncontracting.


p.793, icon at Example 13

#1.
(a) What is the Backus-Naur form of the grammar described as follows:
  1. a sentence is made up of a noun phrase followed by a verb phrase or else by a noun phrase followed by a verb phrase followed by a noun phrase. 
  2. A noun phrase is made up of a noun, an adjective followed by a noun, or an article followed by a noun.
  3. A verb phrase is made up of a verb.
  4. Articles are a and the.
  5. Adjectives are lengthy, boring, and inaccurate.
  6. Nouns are book, newspaper, and information.
  7. Verbs are reads and contains.
(b) Explain how “the newspaper contains lengthy information” can be obtained.


Solution:
(a)
  1. sentence ::= noun phrase verb phrase | noun phrase verb phrase noun phrase 
  2. noun phrase ::= noun | article noun | adjective noun 
  3. verb phrase ::= verb 
  4. article ::= a | the
  5. adjective ::= lengthy | boring | inaccurate
  6. noun ::= newspaper | information
  7. verb ::= reads | contains
(b) “the newspaper” is a noun phrase since it has the form article noun ; “contains” is a verb phrase since it has the form verb ; “lengthy information” is a noun phrase since it has the form adjective noun .
Therefore “the newspaper contains lengthy information” is a sentence since it has the form noun phrase verb phrase noun phrase

Monday, December 19, 2011

Graphs Paths

Graphs Paths

The notion of a path in a graph is intuitively clear but a little hard to pin down formally.
Suppose G(V,E) is a graph with vertices v0,v1,…,vk (not necessarily distinct) and edges e1,e2,…,ek (not necessarily distinct) in which edge ei={vi-1,vi} for i=1,…,k. Then the alternating sequence of vertices and edges v0e1v1e2v2…ekvk is a path from v0 to vk of length k (note that the length is the number of edges, not vertices). Unless we work with multigraphs the listing of the edges is redundant, so we may speak more simply of the path as v0v1v2…vk. This definition allows for incredibly knotty, repetitious paths. If we want to rule out that possibility, we can speak of simple paths, which are paths in which no vertices (and thus no edges) are repeated.

Graphs Representation

Graphs Representation

Normally we think of a graph as a drawing. A little reflection shows that the definition above is a formalization of this intuition about graphs. We think of a graph comprising dots (vertices) connected by line segments or curves (edges). We give every dot a label and form the vertex set V out of the labels. If there is a curve connecting dots a and b, we include the edge {a,b} in E.

From English to Proposition

From English to Proposition

Translation of English sentences to propositions

As we are going to see in the next section, reasoning is done on propositions using inference rules. For example, if the two propositions "if it snows, then the school is closed", and "it snows" are true, then we can conclude that "the school is closed" is true. In everyday life, that is how we reason.

To check the correctness of reasoning, we must check whether or not rules of inference have been followed to draw the conclusion from the premises. However, for reasoning in English or in general for reasoning in a natural language, that is not necessarily straightforward and it often encounters some difficulties. Firstly, connectives are not necessarily easily identified as we can get a flavor of that from the previous topic on variations of if_then statements. Secondly, if the argument becomes complicated involving many statements in a number of different forms twisted and tangled up, it can easily get out of hand unless it is simplified in some way.

One solution for that is to use symbols (and mechanize it). Each sentence is represented by symbols representing building block sentences, and connectives. For example, if P represents "it snows" and Qrepresents "the school is closed", then the previous argument can be expressed as


[ [ P -> Q ] ^ P ] -> Q ,

or

P -> Q

P ----------------------------- Q

This representation is concise, much simpler and much easier to deal with. In addition today there are a number of automatic reasoning systems and we can verify our arguments in symbolic form using them. One such system called TPS is used for reasoning exercises in this course. For example, we can check the correctness of our argument using it.

To convert English statements into a symbolic form, we restate the given statements using the building block sentences, those for which symbols are given, and the connectives of propositional logic (not, and, or, if_then, if_and_only_if), and then substitute the symbols for the building blocks and the connectives.

For example, let P be the proposition "It is snowing", Q be the proposition "I will go the beach", and R be the proposition "I have time".

Then first "I will go to the beach if it is not snowing" is restated as "If it is not snowing, I will go to the beach". Then symbols P and Q are substituted for the respective sentences to obtain ~P -> Q.

Similarly, "It is not snowing and I have time only if I will go to the beach" is restated as "If it is not snowing and I have time, then I will go to the beach", and it is translated as ( ~P ^ R ) -> Q.

If-Then Variations

If Then Variations
different ways of saying if_then: only if, necessary, sufficient


If-then statements appear in various forms in practice. The following list presents some of the variations. These are all logically equivalent, that is as far as true or false of statement is concerned there is no difference between them. Thus if one is true then all the others are also true, and if one is false all the others are false.
  • If p , then q.
  • p implies q.
  • If p,   q.
  • p only if q.
  • p is sufficient for q.
  • q if p.
  • q whenever p.
  • q is necessary for p.
  • It is necessary for p that q.
For instance, instead of saying "If she smiles then she is happy", we can say "If she smiles, she is happy", "She is happy whenever she smiles", "She smiles only if she is happy" etc. without changing their truth values. 


"Only if" can be translated as "then". For example, "She smiles only if she is happy" is equivalent to "If she smiles, then she is happy". 
Note that "She smiles only if she is happy" means "If she is not happy, she does not smile", which is the contrapositive of "If she smiles, she is happy". 
You can also look at it this way: "She smiles only if she is happy" means "She smiles only when she is happy". So any time you see her smile you know she is happy. Hence "If she smiles, then she is happy". Thus they are logically equivalent. 


Also "If she smiles, she is happy" is equivalent to "It is necessary for her to smile that she is happy". For "If she smiles, she is happy" means "If she smiles, she is always happy". That is, she never fails to be happy when she smiles. "Being happy" is inevitable consequence/necessity of "smile". Thus if "being happy" is missing, then "smile" can not be there either. "Being happy" is necessary "for her to smile" or equivalently "It is necessary for her to smile that she is happy". 

source: http://www.cs.odu.edu/~toida/nerzic/content/logic/prop_logic/if_then/if_then.html

Converse and Contrapositive

Converse and Contrapositive
  • converse of proposition
  • contrapositive of proposition
For the proposition P  Q,  the proposition Q  P is called its converse,  and the proposition  Q   P is called its contrapositive.For example for the proposition "If it rains,  then I get wet",

Converse: If I get wet,  then it rains.


Contrapositive: If I don't get wet,  then it does not rain.
The converse of a proposition is not necessarily logically equivalent to it, that is they may or may not take the same truth value at the same time.

On the other hand, the contrapositive of a proposition is always logically equivalent to the proposition. That is, they take the same truth value regardless of the values of their constituent variables. Therefore, "If it rains,  then I get wet." and "If I don't get wet,  then it does not rain." are logically equivalent. If one is true then the other is also true, and vice versa.
  

Construction of Complex Propositions


Syntax of propositions

First it is informally shown how complex propositions are constructed from simple ones. Then more general way of constructing propositions is given.

In everyday life we often combine propositions to form more complex propositions without paying much attention to them. For example combining "Grass is green", and "The sun is red" we say something like "Grass is green and the sun is red", "If the sun is red, grass is green", "The sun is red and the grass is not green" etc. Here "Grass is green", and "The sun is red" are propositions, and form them using connectives "and", "if... then ..." and "not" a little more complex propositions are formed. These new propositions can in turn be combined with other propositions to construct more complex propositions. They then can be combined to form even more complex propositions. This process of obtaining more and more complex propositions can be described more generally as follows:

Let X and Y represent arbitrary propositions. Then
[ X],   [X  Y],  [X  Y],   [X  Y],   and   [X  Y]
are propositions


Note that X and Y here represent an arbitrary proposition.
This is actually a part of more rigorous definition of proposition which we see later.

Example : [ P -> [Q V R] ] is a proposition and it is obtained by first constructing [Q V R] by applying [X V Y] to propositions Q and R considering them as X and Y, respectively, then by applying [ X -> Y ] to the two propositions P and [Q V R] considering them as X and Y, respectively. 

ref: http://www.cs.odu.edu/~toida/nerzic/content/logic/prop_logic/construction/construction.html

Connectives: Meaning of the Connectives

Meaning of connectives:

NOT, AND, OR, IMPLIES, IF AND ONLY IF


Let us define the meaning of the five connectives by showing the relationship between the truth value (i.e. true or false) of composite propositions and those of their component propositions. They are going to be shown using truth table. In the tables P and Q represent arbitrary propositions, and true and false are represented by T and F, respectively.
NOT
P P
TF
FT







This table shows that if P is true, then ( P) is false, and that if P is false, then ( P) is true. 


AND
PQ(P  Q)
FFF
FTF
TFF
TTT










This table shows that (P  Q) is true if both P and Q are true, and that it is false in any other case.
Similarly for the rest of the tables.


OR
PQ(P  Q)
FFF
FTT
TFT
TTT











IMPLIES
PQ(P  Q)
FFT
FTT
TFF
TTT










When P  Q is always true, we express that by P  Q. That is P  Q is used when proposition P always implies proposition Q regardless of the value of the variables in them. See Implications for examples of 

Also see a note on the truth value of IMPLIES when P is False. 


IF AND ONLY IF
  P  Q  ( P  Q )
  F  FT
  F  TF
  T  FF
  T  TT










When P  Q is always true, we express that by P  Q. That is  is used when two propositions always take the same value regardless of the value of the variables in them. See Identities for examples of 

ref: http://www.cs.odu.edu/~toida/nerzic/content/logic/prop_logic/connectives/connectives.html

Elements of Propositional Logic

Simple sentences which are true or false are basic propositions. Larger and more complex sentences are constructed from basic propositions by combining them with connectives. Thus propositions andconnectives are the basic elements of propositional logic. Though there are many connectives, we are going to use the following five basic connectives here: 

        NOT,  AND,  OR,  IF_THEN (or IMPLY),  IF_AND_ONLY_IF.
They are also denoted by the symbols:

          ,   ,   ,   ,   ,

respectively. 
ref: http://www.cs.odu.edu/~toida/nerzic/content/logic/prop_logic/elements/elements.html

What Is Proposition ?

What Is Proposition ?

Sentences considered in propositional logic are not arbitrary sentences but are the ones that are either true or false, but not both. This kind of sentences are called propositions.

If a proposition is true, then we say it has a truth value of "true"; if a proposition is false, its truth value is "false". For example, "Grass is green", and "2 + 5 = 5" are propositions.

The first proposition has the truth value of "true" and the second "false". But "Close the door", and "Is it hot outside ?"are not propositions.

Also "x is greater than 2", where x is a variable representing a number, is not a proposition, because unless a specific value is given to x we can not say whether it is true or false, nor do we know what x represents. Similarly "x = x" is not a proposition because we don't know what "x" represents hence what "=" means.

For example, while we understand what "3 = 3" means, what does "Air is equal to air" or "Water is equal to water" mean ? Does it mean a mass of air is equal to another mass or the concept of air is equal to the concept of air ? We don't quite know what "x = x" mean. Thus we can not say whether it is true or not. Hence it is not a proposition.

Cubic graph


Cubic graph


In the mathematical field of graph theory, a cubic graph is a graph in which all vertices have degree three. In other words a cubic graph is a 3-regular graph. Cubic graphs are also called trivalent graphs.
bicubic graph is a cubic bipartite graph.

Polyhedral Graph



Polyhedral Graph is A graph made up of the vertices and edges of a polyhedron. Polyhedral graphs are always planar.


In geometric graph theory, a branch of mathematics, a polyhedral graph is the undirected graph formed from the vertices and edges of aconvex polyhedron. According to Steinitz's theorem, the polyhedral graphs may also be characterized in purely graph-theoretic terms, as the 3-vertex-connected planar graphs.

Planar Graph

Planar Graph

A graph that can be drawn in a plane without any graph edges intersecting.


In graph theory, a planar graph is a graph that can be embedded in the plane, i.e., it can be drawn on the plane in such a way that its edges intersect only at their endpoints. In other words, it can be drawn in such a way that no edges cross each other.
A planar graph already drawn in the plane without edge intersections is called a plane graph or planar embedding of the graph. A plane graph can be defined as a planar graph with a mapping from every node to a point in 2D space, and from every edge to a plane curve, such that the extreme points of each curve are the points mapped from its end nodes, and all curves are disjoint except on their extreme points. Plane graphs can be encoded by combinatorial maps.
It is easily seen that a graph that can be drawn on the plane can be drawn on the sphere as well, and vice versa.
The equivalence class of topologically equivalent drawings on the sphere is called a planar map. Although a plane graph has an external orunbounded face, none of the faces of a planar map have a particular status.

Graph cycle

Graph cycle


Any of a graph's edge-set subsets that forms a path, the first node of which is also the last.

Permutation

Permutation

A rearrangement of the elements in an ordered list S into a one-to-one correspondence with S itself. Combinatorics studies the number of possible ways of doing this under various conditions.


There are basically two types of permutation:
  1. Repetition is Allowed also known as permutations with repetition
  2. No Repetition: for example the first three people in a running race. You can't be first and second, also known as permutations without repetition.

Recurrence relation

Recurrence relation
A mathematical relationship expressing the members of a sequence as some combination of their predecessors.

Pascal's triangle


A triangular array of binomial coefficients that can visually illustrate several of their properties.

Fibonacci number


A member of the Fibonacci sequence. The Fibonacci sequence is generated by beginning with 1123 and continuing so that subsequent terms are the sum of the two previous numbers.

Binomial theorem

Binomial theorem


Binomial theorem is A formula describing how to expand powers of a binomial (x+a)n using binomial coefficients.

Binomial coefficient

Binomial coefficient


Binomial coefficient  is The number of ways of picking k unordered outcomes from n possibilities, also known as a combination or combinatorial number.

Saturday, December 17, 2011

Concepts in discrete mathematics


Concepts in discrete mathematics

Sets

  • Set (mathematics) –
    • Element (mathematics) –
    • Venn diagram –
    • Empty set –
    • Subset –
    • Union (set theory) –
      • Disjoint union –
    • Intersection (set theory) –
      • Disjoint sets –
    • Complement (set theory) –
    • Symmetric difference –
  • Ordered pair –
  • Cartesian product –
  • Power set –
  • Simple theorems in the algebra of sets –
  • Naive set theory –
  • Multiset –

Functions

  • Function –
  • Domain of a function –
  • Codomain –
  • Range of a function –
  • Image (mathematics) –
  • Injective function –
  • Surjection –
  • Bijection –
  • Function composition –
  • Partial function –
  • Multivalued function –
  • Binary function –
  • Floor function –
  • Sign function –
  • Inclusion map –
  • Pigeonhole principle –
  • Relation composition –
  • Permutations –
  • Symmetry –

Operations

Binary operator –
  • Associativity –
  • Commutativity –
  • Distributivity

Arithmetic

Decimal –
  • Binary numeral system –
  • Divisor –
  • Division by zero –
  • Indeterminate form –
  • Empty product –
  • Euclidean algorithm –
  • Fundamental theorem of arithmetic –
  • Modular arithmetic –
  • Successor function

Elementary algebra

Left-hand side and right-hand side of an equation –
  • Linear equation –
  • Quadratic equation –
  • Solution point –
  • Arithmetic progression –
  • Recurrence relation –
  • Finite difference –
  • Difference operator –
  • Groups –
  • Group isomorphism –
  • Subgroups –
  • Fermat's little theorem –
  • Cryptography –
  • Faulhaber's formula –

Mathematical relations

  • Binary relation –
  • Mathematical relation –
  • Reflexive relation –
  • Reflexive property of equality –
  • Symmetric relation –
  • Symmetric property of equality –
  • Antisymmetric relation –
  • Transitivity (mathematics) –
  • Transitive closure –
  • Transitive property of equality –
  • Equivalence and identity
  • Equivalence relation –
  • Equivalence class –
  • Equality (mathematics) –
  • Inequation –
  • Inequality (mathematics) –
  • Similarity (geometry) –
  • Congruence (geometry) –
  • Equation –
  • Identity (mathematics) –
  • Identity element –
  • Identity function –
  • Substitution property of equality –
  • Graphing equivalence –
  • Extensionality –
  • Uniqueness quantification –

Mathematical phraseology

If and only if –
Necessary and sufficient (Sufficient condition) –
Distinct –
Difference –
Absolute value –
Up to –
Modular arithmetic –
Characterization (mathematics) –
Normal form –
Canonical form –
Without loss of generality –
Vacuous truth –
Contradiction, Reductio ad absurdum –
Counterexample –
Sufficiently large –
Pons asinorum –
Table of mathematical symbols –
Contrapositive –
Mathematical induction –

Combinatorics

  • Permutations and combinations –
  • Permutation –
  • Combination –
  • Factorial –
  • Empty product –
  • Pascal's triangle –
  • Combinatorial proof –
  • Bijective proof –
  • Double counting (proof technique) –

Probability

  • Average –
  • Expected value –
  • Discrete random variable –
  • Sample space –
  • Event –
  • Conditional Probability –
  • Independence –
  • Random variables –

Propositional logic

Logical operator –
Truth table –
De Morgan's laws –
Open sentence –
List of topics in logic –