Use mathematical induction to verify the formula derived in Example 2 for the number of moves required to complete the Tower of Hanoi puzzle.

Bryan L.

Numerade Educator

a) Find a recurrence relation for the number of permutations of a set with n elements.

b) Use this recurrence relation to find the number of permutations of a set with n elements using iteration.

Bryan L.

Numerade Educator

A vending machine dispensing books of stamps accepts only one-dollar coins, $\$ 1$ bills, and $\$ 5$ bills.

a) Find a recurrence relation for the number of ways to deposit $n$ dollars in the vending machine, where

the order in which the coins and bills are deposited matters.

b) What are the initial conditions?

c) How many ways are there to deposit $\$ 10$ for a book of stamps?

Bryan L.

Numerade Educator

A country uses as currency coins with values of 1 peso, 2 pesos, 5 pesos, and 10 pesos and bills with values of 5 pesos, 10 pesos, 20 pesos, 50 pesos, and 100 pesos. Find a recurrence relation for the number of ways to pay a bill of $n$ pesos if the order in which the coins and bills are paid matters.

Bryan L.

Numerade Educator

How many ways are there to pay a bill of 17 pesos using the currency described in Exercise 4, where the order in which coins and bills are paid matters?

Bryan L.

Numerade Educator

a) Find a recurrence relation for the number of strictly increasing sequences of positive integers that have 1 as their first term and $n$ as their last term, where $n$ is a positive integer. That is, sequences $a_{1}, a_{2}, \ldots, a_{k}$ where $a_{1}=1, \quad a_{k}=n, \quad$ and $\quad a_{j}<a_{j+1} \quad$ for $j=$ $1,2, \ldots, k-1$

b) What are the initial conditions?

c) How many sequences of the type described in (a) are there when $n$ is an integer with $n \geq 2 ?$

Bryan L.

Numerade Educator

a) Find a recurrence relation for the number of bit strings of length n that contain a pair of consecutive 0s.

b) What are the initial conditions?

c) How many bit strings of length seven contain two consecutive 0s?

Bryan L.

Numerade Educator

a) Find a recurrence relation for the number of bit strings of length n that contain three consecutive 0s.

b) What are the initial conditions?

c) How many bit strings of length seven contain three consecutive 0s?

Bryan L.

Numerade Educator

a) Find a recurrence relation for the number of bit strings of length n that do not contain three consecutive 0s.

b) What are the initial conditions?

c) How many bit strings of length seven do not contain three consecutive 0s?

Bryan L.

Numerade Educator

a) Find a recurrence relation for the number of bit strings of length $n$ that contain the string $01 .$

b) What are the initial conditions?

c) How many bit strings of length seven contain the string 01$?$

Bryan L.

Numerade Educator

a) Find a recurrence relation for the number of ways to climb n stairs if the person climbing the stairs can take one stair or two stairs at a time.

b) What are the initial conditions?

c) In how many ways can this person climb a flight of eight stairs?

Bryan L.

Numerade Educator

a) Find a recurrence relation for the number of ways to climb n stairs if the person climbing the stairs can take one, two, or three stairs at a time.

b) What are the initial conditions?

c) In how many ways can this person climb a flight of eight stairs?

A string that contains only $0 \mathrm{s}, 1 \mathrm{s},$ and 2 $\mathrm{s}$ is called a ternary string.

Bryan L.

Numerade Educator

a) Find a recurrence relation for the number of ternary strings of length n that do not contain two consecutive 0s.

b) What are the initial conditions?

c) How many ternary strings of length six do not contain two consecutive 0s?

Bryan L.

Numerade Educator

a) Find a recurrence relation for the number of ternary strings of length n that contain two consecutive 0s.

b) What are the initial conditions?

c) How many ternary strings of length six contain two consecutive 0s?

Bryan L.

Numerade Educator

a) Find a recurrence relation for the number of ternary strings of length n that do not contain two consecutive 0s or two consecutive 1s.

b) What are the initial conditions?

c) How many ternary strings of length six do not contain two consecutive 0s or two consecutive 1s?

Bryan L.

Numerade Educator

a) Find a recurrence relation for the number of ternary strings of length n that contain either two consecutive 0s or two consecutive 1s.

b) What are the initial conditions?

c) How many ternary strings of length six contain two consecutive 0s or two consecutive 1s?

Check back soon!

a) Find a recurrence relation for the number of ternary strings of length $n$ that do not contain consecutive symbols that are the same.

b) What are the initial conditions?

c) How many ternary strings of length six do not contain consecutive symbols that are the same?

Bryan L.

Numerade Educator

a) Find a recurrence relation for the number of ternary strings of length $n$ that contain two consecutive symbols that are the same.

b) What are the initial conditions?

c) How many ternary strings of length six contain consecutive symbols that are the same?

Bryan L.

Numerade Educator

Messages are transmitted over a communications channel using two signals. The transmittal of one signal requires 1 microsecond, and the transmittal of the other signal requires 2 microseconds.

a) Find a recurrence relation for the number of different messages consisting of sequences of these two signals, where each signal in the message is immediately followed by the next signal, that can be sent in n microseconds.

b) What are the initial conditions?

c) How many different messages can be sent in 10 microseconds using these two signals?

Bryan L.

Numerade Educator

A bus driver pays all tolls, using only nickels and dimes, by throwing one coin at a time into the mechanical toll collector.

a) Find a recurrence relation for the number of different ways the bus driver can pay a toll of n cents (where the order in which the coins are used matters).

b) In how many different ways can the driver pay a toll of 45 cents?

Bryan L.

Numerade Educator

a) Find the recurrence relation satisfied by $R_{n},$ where $R_{n}$ is the number of regions that a plane is divided into by $n$ lines, if no two of the lines are parallel and no three of the lines go through the same point.

b) Find $R_{n}$ using iteration.

Bryan L.

Numerade Educator

a) Find the recurrence relation satisfied by $R_{n},$ where $R_{n}$ is the number of regions into which the surface of a sphere is divided by $n$ great circles (which are the intersections of the sphere and planes passing through the center of the sphere), if no three of the great circles go through the same point.

b) Find $R_{n}$ using iteration.

Bryan L.

Numerade Educator

a) Find the recurrence relation satisfied by $S_{n},$ where $S_{n}$ is the number of regions into which three-dimensional space is divided by $n$ planes if every three of the planes meet in one point, but no four of the planes go through the same point,

b) Find $S_{n}$ using iteration.

Ibrahima B.

Numerade Educator

Find a recurrence relation for the number of bit sequences of length $n$ with an even number of 0 $\mathrm{s}$ .

Bryan L.

Numerade Educator

How many bit sequences of length seven contain an even number of 0 $\mathrm{s} ?$

Bryan L.

Numerade Educator

a) Find a recurrence relation for the number of ways to completely cover a $2 \times n$ checkerboard with $1 \times 2$ dominoes. [Hint: Consider separately the coverings where the position in the top right corner of the checkerboard is covered by a domino positioned horizontally and where it is covered by a domino positioned vertically.]

b) What are the initial conditions for the recurrence relation in part (a)?

c) How many ways are there to completely cover a $2 \times$ 17 checkerboard with $1 \times 2$ dominoes?

Bryan L.

Numerade Educator

a) Find a recurrence relation for the number of ways to layout a walkway with slate tiles if the tiles are red, green, or gray, so that no two red tiles are adjacent and tiles of the same color are considered indistinguishable.

b) What are the initial conditions for the recurrence relation in part (a)?

c) How many ways are there to lay out a path of seven tiles as described in part (a)?

Bryan L.

Numerade Educator

Show that the Fibonacci numbers satisfy the recurrence relation $f_{n}=5 f_{n-4}+3 f_{n-5}$ for $n=5,6,7, \ldots,$ together with the initial conditions $f_{0}=0, f_{1}=1, f_{2}=1, f_{3}=2$ and $f_{4}=3 .$ Use this recurrence relation to show that $f_{5 n}$ is divisible by $5,$ for $n=1,2,3, \ldots$

Bryan L.

Numerade Educator

Let $S(m, n)$ denote the number of onto functions from a set with $m$ elements to a set with $n$ elements. Show that $S(m, n)$ satisfies the recurrence relation

$$

S(m, n)=n^{m}-\sum_{k=1}^{n-1} C(n, k) S(m, k)

$$

whenever $m \geq n$ and $n>1,$ with the initial condition $S(m, 1)=1$.

Check back soon!

a) Write out all the ways the product $x_{0} \cdot x_{1} \cdot x_{2} \cdot x_{3} \cdot x_{4}$ can be parenthesized to determine the order of multiplication.

b) Use the recurrence relation developed in Example 5 to calculate $C_{4},$ the number of ways to parenthesize the product of five numbers so as to determine the order of multiplication. Verify that you listed the correct number of ways in part (a).

c) Check your result in part (b) by finding $C_{4},$ using the closed formula for $C_{n}$ mentioned in the solution of Example $5 .$

Bryan L.

Numerade Educator

a) Use the recurrence relation developed in Example 5 to determine $C_{5},$ the number of ways to parenthesize the product of six numbers so as to determine the order of multiplication.

b) Check your result with the closed formula for $C_{5}$ mentioned in the solution of Example 5 .

Bryan L.

Numerade Educator

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) Show that every allowable arrangement of the $n$ disks occurs in the solution of this variation of the puzzle.

Ibrahima B.

Numerade Educator

Exercises 33–37 deal with a variation of the Josephus problem described by Graham, Knuth, and Patashnik in [GrKnPa94]. This problem is based on an account by the historian Flavius Josephus, who was part of a band of 41 Jewish rebels trapped in a cave by the Romans during the Jewish Roman war of the first century. The rebels preferred suicide to capture; they decided to form a circle and to repeatedly count off around the circle, killing every third rebel left alive. However, Josephus and another rebel did not want to be killed this way; they determined the positions where they should stand to be the last two rebels remaining alive. The variation we consider begins with n people, numbered 1 to n, standing around a circle. In each stage, every second person still left alive is eliminated until only one survives. We denote the number of the survivor by J(n).

Determine the value of $J(n)$ for each integer $n$ with $1 \leq$ $n \leq 16 .$

Bryan L.

Numerade Educator

Exercises 33–37 deal with a variation of the Josephus problem described by Graham, Knuth, and Patashnik in [GrKnPa94]. This problem is based on an account by the historian Flavius Josephus, who was part of a band of 41 Jewish rebels trapped in a cave by the Romans during the Jewish Roman war of the first century. The rebels preferred suicide to capture; they decided to form a circle and to repeatedly count off around the circle, killing every third rebel left alive. However, Josephus and another rebel did not want to be killed this way; they determined the positions where they should stand to be the last two rebels remaining alive. The variation we consider begins with n people, numbered 1 to n, standing around a circle. In each stage, every second person still left alive is eliminated until only one survives. We denote the number of the survivor by J(n).

Use the values you found in Exercise 33 to conjecture a formula for $J(n) .\left[\text { Hint: Write } n=2^{m}+k, \text { where } m \text { is a }\right.$ nonnegative integer and $k$ is a nonnegative integer less than $2^{m} . ]$

Bryan L.

Numerade Educator

Exercises 33–37 deal with a variation of the Josephus problem described by Graham, Knuth, and Patashnik in [GrKnPa94]. This problem is based on an account by the historian Flavius Josephus, who was part of a band of 41 Jewish rebels trapped in a cave by the Romans during the Jewish Roman war of the first century. The rebels preferred suicide to capture; they decided to form a circle and to repeatedly count off around the circle, killing every third rebel left alive. However, Josephus and another rebel did not want to be killed this way; they determined the positions where they should stand to be the last two rebels remaining alive. The variation we consider begins with n people, numbered 1 to n, standing around a circle. In each stage, every second person still left alive is eliminated until only one survives. We denote the number of the survivor by J(n).

Show that $J(n)$ satisfies the recurrence relation $J(2 n)=$ $2 J(n)-1$ and $J(2 n+1)=2 J(n)+1,$ for $n \geq 1,$ and $J(1)=1$

Bryan L.

Numerade Educator

Exercises 33–37 deal with a variation of the Josephus problem described by Graham, Knuth, and Patashnik in [GrKnPa94]. This problem is based on an account by the historian Flavius Josephus, who was part of a band of 41 Jewish rebels trapped in a cave by the Romans during the Jewish Roman war of the first century. The rebels preferred suicide to capture; they decided to form a circle and to repeatedly count off around the circle, killing every third rebel left alive. However, Josephus and another rebel did not want to be killed this way; they determined the positions where they should stand to be the last two rebels remaining alive. The variation we consider begins with n people, numbered 1 to n, standing around a circle. In each stage, every second person still left alive is eliminated until only one survives. We denote the number of the survivor by J(n).

Use mathematical induction to prove the formula you conjectured in Exercise $34,$ making use of the recurrence relation from Exercise $35 .$

Bryan L.

Numerade Educator

Exercises 33–37 deal with a variation of the Josephus problem described by Graham, Knuth, and Patashnik in [GrKnPa94]. This problem is based on an account by the historian Flavius Josephus, who was part of a band of 41 Jewish rebels trapped in a cave by the Romans during the Jewish Roman war of the first century. The rebels preferred suicide to capture; they decided to form a circle and to repeatedly count off around the circle, killing every third rebel left alive. However, Josephus and another rebel did not want to be killed this way; they determined the positions where they should stand to be the last two rebels remaining alive. The variation we consider begins with n people, numbered 1 to n, standing around a circle. In each stage, every second person still left alive is eliminated until only one survives. We denote the number of the survivor by J(n).

Determine $J(100), J(1000),$ and $J(10,000)$ from your formula for $J(n) .$

Bryan L.

Numerade Educator

Exercises $38-45$ involve the Reve's puzzle, the variation of the Tower of Hanoi puzzle with four pegs and $n$ disks. Before presenting these exercises, we describe the Frame-Stewart algorithm for moving the disks from peg 1 to peg 4 so that no disk is ever on top of a smaller one. This algorithm, given the number of disks $n$ as input, depends on a choice of an integer $k$ with $1 \leq k \leq n .$ When there is only one disk, move it from peg 1 to peg 4 and stop. For $n>1$ , the algorithm proceeds recursively, using these three steps. Recursively move the stack of the $n-k$ smallest disks from peg 1 to peg $2,$ using all four pegs. Next move the stack of the $k$ largest disks from peg 1 to peg $4,$ using the three-peg algorithm from the Tower of Hanoi puzzle without using the peg holding the $n-k$ smallest disks. Finally, recursively move the smallest $n-k$ disks to peg $4,$ using all four pegs. Frame and Stewart showed that to produce the fewest moves using their algorithm, $k$ should be chosen to be the smallest integer such that $n$ does not exceed $t_{k}=k(k+1) / 2,$ the $k$ th triangular number, that is, $t_{k-1}<n \leq t_{k}$ . The long-standing conjecture, known as Frame's conjecture, that this algorithm uses the fewest number of moves required to solve the puzzle, was proved by Thierry Bousch in 2014 .

Show that the Reve's puzzle with three disks can be solved using five, and no fewer, moves.

Bryan L.

Numerade Educator

Exercises $38-45$ involve the Reve's puzzle, the variation of the Tower of Hanoi puzzle with four pegs and $n$ disks. Before presenting these exercises, we describe the Frame-Stewart algorithm for moving the disks from peg 1 to peg 4 so that no disk is ever on top of a smaller one. This algorithm, given the number of disks $n$ as input, depends on a choice of an integer $k$ with $1 \leq k \leq n .$ When there is only one disk, move it from peg 1 to peg 4 and stop. For $n>1$ , the algorithm proceeds recursively, using these three steps. Recursively move the stack of the $n-k$ smallest disks from peg 1 to peg $2,$ using all four pegs. Next move the stack of the $k$ largest disks from peg 1 to peg $4,$ using the three-peg algorithm from the Tower of Hanoi puzzle without using the peg holding the $n-k$ smallest disks. Finally, recursively move the smallest $n-k$ disks to peg $4,$ using all four pegs. Frame and Stewart showed that to produce the fewest moves using their algorithm, $k$ should be chosen to be the smallest integer such that $n$ does not exceed $t_{k}=k(k+1) / 2,$ the $k$ th triangular number, that is, $t_{k-1}<n \leq t_{k}$ . The long-standing conjecture, known as Frame's conjecture, that this algorithm uses the fewest number of moves required to solve the puzzle, was proved by Thierry Bousch in 2014 .

Show that the Reve's puzzle with four disks can be solved using nine, and no fewer, moves.

Bryan L.

Numerade Educator

Exercises $38-45$ involve the Reve's puzzle, the variation of the Tower of Hanoi puzzle with four pegs and $n$ disks. Before presenting these exercises, we describe the Frame-Stewart algorithm for moving the disks from peg 1 to peg 4 so that no disk is ever on top of a smaller one. This algorithm, given the number of disks $n$ as input, depends on a choice of an integer $k$ with $1 \leq k \leq n .$ When there is only one disk, move it from peg 1 to peg 4 and stop. For $n>1$ , the algorithm proceeds recursively, using these three steps. Recursively move the stack of the $n-k$ smallest disks from peg 1 to peg $2,$ using all four pegs. Next move the stack of the $k$ largest disks from peg 1 to peg $4,$ using the three-peg algorithm from the Tower of Hanoi puzzle without using the peg holding the $n-k$ smallest disks. Finally, recursively move the smallest $n-k$ disks to peg $4,$ using all four pegs. Frame and Stewart showed that to produce the fewest moves using their algorithm, $k$ should be chosen to be the smallest integer such that $n$ does not exceed $t_{k}=k(k+1) / 2,$ the $k$ th triangular number, that is, $t_{k-1}<n \leq t_{k}$ . The long-standing conjecture, known as Frame's conjecture, that this algorithm uses the fewest number of moves required to solve the puzzle, was proved by Thierry Bousch in 2014 .

Describe the moves made by the Frame-Stewart algorithm, with $k$ chosen so that the fewest moves are required, for

$\begin{array}{llll}{\text { a) } 5 \text { disks. }} & {\text { b) } 6 \text { disks. }} & {\text { c) } 7 \text { disks. }} & {\text { d) } 8 \text { disks. }}\end{array}$

Bryan L.

Numerade Educator

Exercises $38-45$ involve the Reve's puzzle, the variation of the Tower of Hanoi puzzle with four pegs and $n$ disks. Before presenting these exercises, we describe the Frame-Stewart algorithm for moving the disks from peg 1 to peg 4 so that no disk is ever on top of a smaller one. This algorithm, given the number of disks $n$ as input, depends on a choice of an integer $k$ with $1 \leq k \leq n .$ When there is only one disk, move it from peg 1 to peg 4 and stop. For $n>1$ , the algorithm proceeds recursively, using these three steps. Recursively move the stack of the $n-k$ smallest disks from peg 1 to peg $2,$ using all four pegs. Next move the stack of the $k$ largest disks from peg 1 to peg $4,$ using the three-peg algorithm from the Tower of Hanoi puzzle without using the peg holding the $n-k$ smallest disks. Finally, recursively move the smallest $n-k$ disks to peg $4,$ using all four pegs. Frame and Stewart showed that to produce the fewest moves using their algorithm, $k$ should be chosen to be the smallest integer such that $n$ does not exceed $t_{k}=k(k+1) / 2,$ the $k$ th triangular number, that is, $t_{k-1}<n \leq t_{k}$ . The long-standing conjecture, known as Frame's conjecture, that this algorithm uses the fewest number of moves required to solve the puzzle, was proved by Thierry Bousch in 2014 .

Show that if $R(n)$ is the number of moves used by the Frame-Stewart algorithm to solve the Reve's puzzle with $n$ disks, where $k$ is chosen to be the smallest integer with $n \leq k(k+1) / 2,$ then $R(n)$ satisfies the recurrence relation $R(n)=2 R(n-k)+2^{k}-1,$ with $R(0)=0$ and $R(1)=1$.

Bryan L.

Numerade Educator

Exercises $38-45$ involve the Reve's puzzle, the variation of the Tower of Hanoi puzzle with four pegs and $n$ disks. Before presenting these exercises, we describe the Frame-Stewart algorithm for moving the disks from peg 1 to peg 4 so that no disk is ever on top of a smaller one. This algorithm, given the number of disks $n$ as input, depends on a choice of an integer $k$ with $1 \leq k \leq n .$ When there is only one disk, move it from peg 1 to peg 4 and stop. For $n>1$ , the algorithm proceeds recursively, using these three steps. Recursively move the stack of the $n-k$ smallest disks from peg 1 to peg $2,$ using all four pegs. Next move the stack of the $k$ largest disks from peg 1 to peg $4,$ using the three-peg algorithm from the Tower of Hanoi puzzle without using the peg holding the $n-k$ smallest disks. Finally, recursively move the smallest $n-k$ disks to peg $4,$ using all four pegs. Frame and Stewart showed that to produce the fewest moves using their algorithm, $k$ should be chosen to be the smallest integer such that $n$ does not exceed $t_{k}=k(k+1) / 2,$ the $k$ th triangular number, that is, $t_{k-1}<n \leq t_{k}$ . The long-standing conjecture, known as Frame's conjecture, that this algorithm uses the fewest number of moves required to solve the puzzle, was proved by Thierry Bousch in 2014 .

Show that if $k$ is as chosen in Exercise $41,$ then $R(n)-R(n-1)=2^{k-1} .$

Check back soon!

Exercises $38-45$ involve the Reve's puzzle, the variation of the Tower of Hanoi puzzle with four pegs and $n$ disks. Before presenting these exercises, we describe the Frame-Stewart algorithm for moving the disks from peg 1 to peg 4 so that no disk is ever on top of a smaller one. This algorithm, given the number of disks $n$ as input, depends on a choice of an integer $k$ with $1 \leq k \leq n .$ When there is only one disk, move it from peg 1 to peg 4 and stop. For $n>1$ , the algorithm proceeds recursively, using these three steps. Recursively move the stack of the $n-k$ smallest disks from peg 1 to peg $2,$ using all four pegs. Next move the stack of the $k$ largest disks from peg 1 to peg $4,$ using the three-peg algorithm from the Tower of Hanoi puzzle without using the peg holding the $n-k$ smallest disks. Finally, recursively move the smallest $n-k$ disks to peg $4,$ using all four pegs. Frame and Stewart showed that to produce the fewest moves using their algorithm, $k$ should be chosen to be the smallest integer such that $n$ does not exceed $t_{k}=k(k+1) / 2,$ the $k$ th triangular number, that is, $t_{k-1}<n \leq t_{k}$ . The long-standing conjecture, known as Frame's conjecture, that this algorithm uses the fewest number of moves required to solve the puzzle, was proved by Thierry Bousch in 2014 .

Show that if $k$ is as chosen in Exercise $41,$ then $R(n)=\sum_{i=1}^{k} i 2^{i-1}-\left(t_{k}-n\right) 2^{k-1}$.

Bryan L.

Numerade Educator

Exercises $38-45$ involve the Reve's puzzle, the variation of the Tower of Hanoi puzzle with four pegs and $n$ disks. Before presenting these exercises, we describe the Frame-Stewart algorithm for moving the disks from peg 1 to peg 4 so that no disk is ever on top of a smaller one. This algorithm, given the number of disks $n$ as input, depends on a choice of an integer $k$ with $1 \leq k \leq n .$ When there is only one disk, move it from peg 1 to peg 4 and stop. For $n>1$ , the algorithm proceeds recursively, using these three steps. Recursively move the stack of the $n-k$ smallest disks from peg 1 to peg $2,$ using all four pegs. Next move the stack of the $k$ largest disks from peg 1 to peg $4,$ using the three-peg algorithm from the Tower of Hanoi puzzle without using the peg holding the $n-k$ smallest disks. Finally, recursively move the smallest $n-k$ disks to peg $4,$ using all four pegs. Frame and Stewart showed that to produce the fewest moves using their algorithm, $k$ should be chosen to be the smallest integer such that $n$ does not exceed $t_{k}=k(k+1) / 2,$ the $k$ th triangular number, that is, $t_{k-1}<n \leq t_{k}$ . The long-standing conjecture, known as Frame's conjecture, that this algorithm uses the fewest number of moves required to solve the puzzle, was proved by Thierry Bousch in 2014 .

Use Exercise 43 to give an upper bound on the number of moves required to solve the Reve's puzzle for all integers $n$ with $1 \leq n \leq 25$ .

Check back soon!

Exercises $38-45$ involve the Reve's puzzle, the variation of the Tower of Hanoi puzzle with four pegs and $n$ disks. Before presenting these exercises, we describe the Frame-Stewart algorithm for moving the disks from peg 1 to peg 4 so that no disk is ever on top of a smaller one. This algorithm, given the number of disks $n$ as input, depends on a choice of an integer $k$ with $1 \leq k \leq n .$ When there is only one disk, move it from peg 1 to peg 4 and stop. For $n>1$ , the algorithm proceeds recursively, using these three steps. Recursively move the stack of the $n-k$ smallest disks from peg 1 to peg $2,$ using all four pegs. Next move the stack of the $k$ largest disks from peg 1 to peg $4,$ using the three-peg algorithm from the Tower of Hanoi puzzle without using the peg holding the $n-k$ smallest disks. Finally, recursively move the smallest $n-k$ disks to peg $4,$ using all four pegs. Frame and Stewart showed that to produce the fewest moves using their algorithm, $k$ should be chosen to be the smallest integer such that $n$ does not exceed $t_{k}=k(k+1) / 2,$ the $k$ th triangular number, that is, $t_{k-1}<n \leq t_{k}$ . The long-standing conjecture, known as Frame's conjecture, that this algorithm uses the fewest number of moves required to solve the puzzle, was proved by Thierry Bousch in 2014 .

Show that $R(n)$ is $O\left(\sqrt{n} 2^{\sqrt{2 n}}\right)$

Check back soon!

Find $\nabla a_{n}$ for the sequence $\left\{a_{n}\right\},$ where

$$

\begin{array}{ll}{\text { a) } a_{n}=4 .} & {\text { b) } a_{n}=2 n} \\ {\text { c) } a_{n}=n^{2}} & {\text { d) } a_{n}=2^{n}}\end{array}

$$

Bryan L.

Numerade Educator

Prove that $a_{n-k}$ can be expressed in terms of $a_{n}, \nabla a_{n}$ $\nabla^{2} a_{n}, \ldots, \nabla^{k} a_{n}$.

Bryan L.

Numerade Educator

Express the recurrence relation $a_{n}=a_{n-1}+a_{n-2}$ in terms of $a_{n}, \nabla a_{n},$ and $\nabla^{2} a_{n}$.

Bryan L.

Numerade Educator

Show that any recurrence relation for the sequence $\left\{a_{n}\right\}$ can be written in terms of $a_{n}, \nabla a_{n}, \nabla^{2} a_{n}, \ldots$ The resulting equation involving the sequences and its differences is called a difference equation.

Bryan L.

Numerade Educator

Construct the algorithm described in the text after Algorithm 1 for determining which talks should be scheduled to maximize the total number of attendees and not just the maximum total number of attendees determined by Algorithm 1.

Bryan L.

Numerade Educator

Use Algorithm 1 to determine the maximum number of total attendees in the talks in Example 6 if $w_{i}$ , the number of attendees of talk $i, i=1,2, \ldots, 7,$ is

$$

\begin{array}{l}{\text { a) } 20,10,50,30,15,25,40} \\ {\text { b) } 100,5,10,20,25,40,30} \\ {\text { c) } 2,3,8,5,4,7,10} \\ {\text { d) } 10,8,7,25,20,30,5}\end{array}

$$

Bryan L.

Numerade Educator

For each part of Exercise $54,$ use your algorithm from Exercise 53 to find the optimal schedule for talks so that the total number of attendees is maximized.

Check back soon!

In this exercise we will develop a dynamic programming algorithm for finding the maximum sum of consecutive terms of a sequence of real numbers. That is, given a sequence of real numbers $a_{1}, a_{2}, \ldots, a_{n}$ the algorithm computes the maximum sum $\sum_{i=j}^{k} a_{i}$ where $1 \leq j \leq k \leq n$.

a) Show that if all terms of the sequence are nonnegative, this problem is solved by taking the sum of all

terms. Then, give an example where the maximum sum of consecutive terms is not the sum of all terms.

b) Let $M(k)$ be the maximum of the sums of consecutive terms of the sequence ending at $a_{k} .$ That is, $M(k)=$ $\max _{1 \leq j \leq k} \sum_{i=j}^{k} a_{i}$ Explain why the recurrence relation $M(k)=\max \left(M(k-1)+a_{k}, a_{k}\right)$ holds for $k=2, \ldots, n$.

c) Use part (b) to develop a dynamic programming algorithm for solving this problem.

d) Show each step your algorithm from part (c) uses to find the maximum sum of consecutive terms of the sequence $2,-3,4,1,-2,3$

e) Show that the worst-case complexity in terms of the number of additions and comparisons of your algorithm from part (c) is linear.

Check back soon!

Dynamic programming can be used to develop an algorithm for solving the matrix-chain multiplication problem introduced in Section $3.3 .$ This is the problem of determining how the product $\mathbf{A}_{1} \mathbf{A}_{2} \cdots \mathbf{A}_{n}$ can be computed using the fewest integer multiplications, where $\mathbf{A}_{1}, \mathbf{A}_{2}, \ldots, \mathbf{A}_{n}$ are $m_{1} \times m_{2}, m_{2} \times m_{3}, \ldots, m_{n} \times m_{n+1}$ matrices, respectively, and each matrix has integer entries. Recall that by the associative law, the product does not depend on the order in which the matrices are multiplied.

a) Show that the brute-force method of determining the minimum number of integer multiplications needed to solve a matrix-chain multiplication problem has exponential worst-case complexity. [Hint: Do this by first showing that the order of multiplication of matrices is specified by parenthesizing the product. Then, use Example 5 and the result of part (c) of Exercise 43 in Section 8.4 .1

b) Denote by $A_{i j}$ the product $\mathbf{A}_{i} \mathbf{A}_{i+1} \ldots, \mathbf{A}_{j}$ and $M(i, j)$ the minimum number of integer multiplications required to find $\mathbf{A}_{i j} .$ Show that if the least number of integer multiplications are used to compute $\mathbf{A}_{i j},$ where $i<j,$ by splitting the product into the product of $\mathbf{A}_{i}$ through $\mathbf{A}_{k}$ and the product of $\mathbf{A}_{k+1}$ through $\mathbf{A}_{j},$ then the first $k$ terms must be parenthesized so that $\mathbf{A}_{i k}$ is computed in the optimal way using $M(i, k)$ integer multiplications, and $\mathbf{A}_{k+1, j}$ must be parenthesized so that $\mathbf{A}_{k+1, j}$ is computed in the optimal way using $M(k+1, j)$ integer multiplications.

c) Explain why part (b) leads to the recurrence relation $M(i, j)=\min _{i \leq k<j}(M(i, k)+M(k+1, j)+$ $\quad m_{i} m_{k+1} m_{j+1} )$ if $1 \leq i \leq j<j \leq n$

d) Use the recurrence relation in part (c) to construct an efficient algorithm for determining the order

the $n$ matrices should be multiplied to use the minimum number of integer multiplications. Store the partial results $M(i, j)$ as you find them so that your algorithm will not have exponential complexity.

e) Show that your algorithm from part (d) has $O\left(n^{3}\right)$ worst-case complexity in terms of multiplications of integers.

Check back soon!