Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Recurrence Relation - Discrete Mathematics - Solved Homework, Slides of Discrete Mathematics

During the study of discrete mathematics, I found this course very informative and applicable.The main points in these lecture slides are:Recurrence Relation, Tower of Hanoi Puzzle, Different Arrangements, Recursive Formula, Deterministic Algorithm, Nonhomogeneous Recurrence, Recurrence Using Annihilators, Linear Recurrence, Asymptotic Solution

Typology: Slides

2012/2013

Uploaded on 04/27/2013

atmaja
atmaja 🇮🇳

4.2

(45)

182 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS173: Discrete Mathematical Structures
Spring 2006
Homework #11
Due 04/23/05, 8a
Solutions, Grading Rubric
(43 Points)
1. (3 points each part for total of 12 points) In the Tower of Hanoi puzzle, suppose
our goal is to transfer all n disks from peg 1 to peg 3, but we cannot move a disk
directly between pegs 1 and 3. Each move of a disk must be a move involving
peg 2. As usual, we cannot place a disk on top of a smaller disk.
a. Find a recurrence relation for the number of moves required to solve the
puzzle for n disks with this added restriction.
b. Solve this recurrence relation to find a formula for the number of moves
required to solve the puzzle for n disks.
c. How many different arrangements are there of the n disks on three pegs so
that no disk is on top of a smaller disk?
d. Use your answers to parts b and c to argue that every allowable
arrangement of the n disks occurs in the solution of this variation of the
puzzle.
Solutions:
a. If we have one disk, then we move it to peg 2, then to peg 3. Thus a1=2.
Suppose the number of moves needed to move n disks from peg 1 to peg 3
is an. To move n+1 pegs, we have to move the n pegs from peg 1 to peg 3,
then move the largest disk to peg 2, then move n disks from peg 3 to peg
1, then move the largest disk to peg 3, and finally move the n disks to peg
3. Thus an= 3an-1+2.
b. (E-1)(E-3)=<0>. Thus the solution is: an=A+B3n. a1=2, a2=8 (you can get
this both from the recursive formula for an and by manually solving the
problem with two disks). We get A+3B=2; A+9B=8. Subtract equations to
get 6B=6. Thus B=1, A=-1, an=3n-1.
c. 3n.
d. During our solution no configuration can appear twice, since we have a
deterministic algorithm here. If we start with configuration X and after k
steps reach configuration X again, then we’ll return to the same
configuration at times k, 2k, 3k,… never solving the problem. Now, we
start with the initial configuration and have additional 3n-1 distinct
configurations until we solve the problem. Thus we see 3n-1+1
configurations during the solutions, which is all the possible
configurations.
2. (3 points each part for total of 15 points) Solve the following recurrences exactly:
Docsity.com
pf3
pf4

Partial preview of the text

Download Recurrence Relation - Discrete Mathematics - Solved Homework and more Slides Discrete Mathematics in PDF only on Docsity!

CS173: Discrete Mathematical Structures

Spring 2006

Homework

Due 04/23/05, 8a

Solutions, Grading Rubric

(43 Points)

  1. (3 points each part for total of 12 points) In the Tower of Hanoi puzzle, suppose our goal is to transfer all n disks from peg 1 to peg 3, but we cannot move a disk directly between pegs 1 and 3. Each move of a disk must be a move involving peg 2. As usual, we cannot place a disk on top of a smaller disk. a. Find a recurrence relation for the number of moves required to solve the puzzle for n disks with this added restriction. b. Solve this recurrence relation to find a formula for the number of moves required to solve the puzzle for n disks. c. How many different arrangements are there of the n disks on three pegs so that no disk is on top of a smaller disk? d. Use your answers to parts b and c to argue that every allowable arrangement of the n disks occurs in the solution of this variation of the puzzle. Solutions: a. If we have one disk, then we move it to peg 2, then to peg 3. Thus a 1 =2. Suppose the number of moves needed to move n disks from peg 1 to peg 3 is an. To move n+1 pegs, we have to move the n pegs from peg 1 to peg 3, then move the largest disk to peg 2, then move n disks from peg 3 to peg 1, then move the largest disk to peg 3, and finally move the n disks to peg 3. Thus an= 3an-1+2. b. (E-1)(E-3)=<0>. Thus the solution is: an=A+B3n. a 1 =2, a 2 =8 (you can get this both from the recursive formula for an and by manually solving the problem with two disks). We get A+3B=2; A+9B=8. Subtract equations to get 6B=6. Thus B=1, A=-1, an=3n-1. c. 3 n. d. During our solution no configuration can appear twice, since we have a deterministic algorithm here. If we start with configuration X and after k steps reach configuration X again, then we’ll return to the same configuration at times k, 2k, 3k,… never solving the problem. Now, we start with the initial configuration and have additional 3n-1 distinct configurations until we solve the problem. Thus we see 3n-1+ configurations during the solutions, which is all the possible configurations.
  2. (3 points each part for total of 15 points) Solve the following recurrences exactly:

a. a (^) n = 2 a (^) n − 1 + 2 n^2 , a (^) 1 = 4. b. a (^) n = − a (^) n − 1 + 2 a (^) n − 2 + 2 n^ −^1 , a (^) 0 = a (^) 1 = 1. c. a^ n^ =^9 a^ n 2

  • n^2 , a (^) 1 = 0. d. a^ n^ =^9 a^ n 4
  • n^2 , a (^) 1 = 0 , a (^) 2 = 1. e. a (^) n = 5 a (^) n 3 − 6 a (^) n 9 − 3 , a (^) 1 = 0 , a (^) 3 = 1 , a (^) 9 = 2. Solutions: a. (E-1) 3 (E-2)< an>=<0>. Thus: an=A+Bn+Cn^2 +D2n. Also: a 1 =4 a 0 =1, a 2 =16, a (^) -1=1/ A-B+C+D/2=1/2  2A-2B+2C+D= A+D= A+B+C+2D= A+2B+4C+4D= The solution to this system is: A=-12,B=-8,C=-2,D=13. The final solution is: an= 132n^ – 12 – 8n – 2n^2 b. (E-2)(E^2 +E-2) < an>=<0>. Thus: an= A2n^ + B(-2)n^ + C(1)n. Also: a 1 =a 0 =1  a 2 = The solution is: A=1/2; B=1/6; C=1/3. an= 2n-1^ - (-2)n-1/3 + 1/ c. Substitution: b(k)=a(2k)=9a(2k-1) + 4k^ = 9b(k-1) + 4k (E-4)(E-9) =<0>. Thus: bn= A4n^ + B9n. Also: b 0 = a(2^0 )=0, b 1 = a(2^1 )=4. The solution is: bn= -4/54n^ +4/59n. And in terms of an, an=-4/54logn^ +4/5*9logn d. a^ n^ =^9 a^ n 4
  • n^2 , a (^) 1 = 0 , a (^) 2 = 1. Substitution: b(k)=a(4k)=9a(4k-1) + 8k^ = 9b(k-1) + 8k (E-8)(E-9) =<0>. Thus: bn= A8n^ + B9n. Also: b 0 = a(4^0 )=0, b 1 = a(4^1 )=16. The solution is: bn= -164n^ +169n. And in terms of an, an=-164logn^ +169logn This is in case n=4k. there is another sequence here: bn= A8n^ + B9n. Also: b 0 = a(4^0 )=0, b1/2= a(41/2)=1. The solution is: bn= -2/(3-sqrt(8))4n^ +2/(3-sqrt(8))9n. And in terms of an, an=-2/(3-sqrt(8))4logn^ +2/(3-sqrt(8))9logn e. a (^) n = 5 a (^) n 3 − 6 a (^) n 9 − 3 , a (^) 1 = 0 , a (^) 3 = 1 , a (^) 9 = 2. Substitution: b(k)=a(3k)=5a(3k-1)-6a(3k-2) -3 = 5b(k-1)-6b(k-2)- (E-1)(E^2 -5E+6) =<0>. Thus: bn= A3n^ + B2n+C. Also: b 0 =0, b 1 =1, b 2 =2. The solution is: bn= (-1/2)3n^ + (2)2n-3/2. And in terms of an, an=(-1/2)3logn^ + (2)2logn-3/

Therefore in the limit an is constant, Θ(1).