Question

In: Computer Science

Discrete Math. An old folktale says that in a faraway monastery there is a platform with...

Discrete Math.

An old folktale says that in a faraway monastery there is a platform with three large posts on it and when the world began there were 64 golden disks stacked on one of the posts. The disks are all of different sizes arranged in order from largest at the bottom to smallest at the top. The disks are being moved from the original post to another according to the following rules:

1. One disk at a time is moved from one post to another.

2. A larger disk may never rest on top of a smaller disk.

3. A disk is either on a post or in motion from one post to another.

When the monks have finished moving the disks from the original post to one of the others, the world will end. How long will the world exist? A useful strategy is to try out smaller cases and look for patterns. Let Nk be the minimum number of moves that are needed to move k disks from one post to another. Then N1 is 1 and N2 is 3. (Verify this.)

1. By experimenting, find N3, N4, N5.

2. Describearecursiveprocessfortransferringkdisksfrompost1topost3.Write an algorithm to carry out your process.

3. Use the recursive process in Question 2 to develop a recurrence relation for Nk .

4. SolvetherecurrencerelationinQuestion3andverifythesolutionbycomparing the results produced by the solution and the values found in Question 1.

5. From Question 4 you have an explicit formula for Nk. Use mathematical in- duction to prove that this statement is true.

6. If the monks move one disk per second and never make a mistake, how long (to the nearest year) will the world exist?

Solutions

Expert Solution

Rules given:

1. One disk at a time is moved from one post to another.

2. A larger disk may never rest on top of a smaller disk.

3. A disk is either on a post or in motion from one post to another.

Let Nk be the minimum number of moves that are needed to move k disks from one post to another. Then:

To answer how long it will take our friendly monks to destroy the world, we write a recurrence (let's call it M(n)) for the number of moves MoveTower takes for an n-disk tower.

The base case - when n is 1: The monks just move the single disk directly, therefore:

N (1) = 1

In the other cases, the monks follow our three-step procedure.

1. First, they move the (n-1)-disk tower to the spare Tower; this takes N(n-1) moves.

2. Then the monks move the nth disk, taking 1 move.

3. And finally, they move the (n-1)-disk tower again, this time on top of the nth disk, taking N(n-1) Noves.

This gives us our recurrence relation,

N(n) = 2 N(n-1) + 1         …(a)

N (2) = 2 N (1) + 1

N(2) = 2.1 + 1                  (as N(1) is 1)

N(2) = 3                           Hence, verified

1) Find N3, N4, N5

Using the above eqn: (a)

N(k) = 2N(k-1) + 1

N(3) = 2N(3-1) + 1 = 2N(2) + 1 = 2.3 + 1 = 7

N(4) = 2N(4-1) + 1 = 2N(3) + 1 = 2.7 + 1 = 15

N(5) = 2N(5-1) + 1 = 2N(4) + 1 = 2.15 + 1 = 31

2) To move n discs from Source Tower to Destination Tower, we can derive an algo like the following steps:

a. Move n−1 discs from A to B. This leaves nth disc alone on Source Tower.

b. Move nth disc from A to C.

c. Move n−1 discs from B to C, so they sit on nth disc.

For E.g., If we take n=3

1. Move 2 discs from A to B (using C) à This is a recursive call.


2. Move a disc from A to C directly.

3. Move 2 discs from B to C (using A) à This is a recursive call.

So, the algorithm (Considering “C” as Base Language)

void TOH(int n, int A, int B, int C)

{

          if (n>0)

          {       

                    TOH(n-1, A, C, B);

                    printf(“Move a disc from %d to %d”, A, C);

                    TOH(n-1, B, A, C);

}

}

3) By looking at Question 2 of solutions, we can guess that

N(n) = 2n - 1

4) Verifying the solution by comparing the results produced by the solution in Question 3 and the values found in Question 1.

N(3) = 23 - 1= 8 - 1= 7

N(4) = 24 - 1= 16 - 1= 15

N(5) = 25 - 1= 32 - 1= 31

5) The Explicit formula N(k) = 2k – 1

We can verify this easily by plugging it into our recurrence.

N(1) = 1 = 21 - 1
N(n) = 2 N(n - 1) + 1 = 2 (2n - 1 + 1) - 1 = 2n + 1

Since our expression 2n+1 is consistent with all the recurrence's cases.

6) If the monks move one disk per second and never make a mistake, then

the monks will move 264+1 (about 18.45x1018) disks. If they are really good and can move one disk a millisecond, then they'll have to work for 584.6 million years. It looks like we're safe.


Related Solutions

[Discrete math] Show that it is possible to arrange the numbers 1, 2, . . ....
[Discrete math] Show that it is possible to arrange the numbers 1, 2, . . . , n in a row so that the average of any two of these numbers never appears between them. [Hint: Show that it suffices to prove this fact when n is a power of 2. Then use mathematical induction to prove the result when n is a power of 2.] I saw the solution but I don't understand why permutation pi is using here.....
Discrete Math: Give examples of relations on the set of humans that are: a) asymmetric and...
Discrete Math: Give examples of relations on the set of humans that are: a) asymmetric and transitive b) symmetric and antisymmetric c) reflexive and irreflexive.
Discrete Math An AZ is a string of English letters with the property that every ‘a’...
Discrete Math An AZ is a string of English letters with the property that every ‘a’ in the string precedes every ‘z’ in the string. For example, each of these strings is an AZ: bedazzled organize paparazzo zipper (we don’t promise a appears) cassette (we don’t promise z appears) monkey (we don’t promise any a or z appears at all) None of these strings is an AZ: za razzmatazz arizona lizard Find a recurrence and appropriate initial conditions for the...
DISCRETE MATH 1.Prove that the set of all integers that are not multiples of three is...
DISCRETE MATH 1.Prove that the set of all integers that are not multiples of three is countable.
Discrete Math. Problem 1. Consider the statement: “If an animal is an rhinoceros, then it has...
Discrete Math. Problem 1. Consider the statement: “If an animal is an rhinoceros, then it has a horn.” (a) Write down the CONVERSE of this statement. (b) Write down the CONTRAPOSITIVE of this statement Problem 2. Let x be a positive real number. Using the definition of rational number, write a proof by contraposition of the following: If x is irrational, then √ x + 6 is also irrational. Problem 3 Let n be an integer. Using the definition of...
Discussion - Relationship of digital and mathematical logic In discrete math, you studied a form of...
Discussion - Relationship of digital and mathematical logic In discrete math, you studied a form of mathematical logic called propositional logic. In this discussion, your task is to research the relationships between propositional logic, Boolean Algebra, and digital logic. Cite your sources and summarize your findings to demonstrate what you learned from the research.
Discrete math problem: Prove that there are infinitely many primes of form 4n+3.
Discrete math problem: Prove that there are infinitely many primes of form 4n+3.
Discrete Math Course. On Z, let B be the set of subsets A of Z where...
Discrete Math Course. On Z, let B be the set of subsets A of Z where either A is finite or A complement is finite. Define + and * as union and interception. Show whether or not B is a boolean algebra.
(Discrete Math) A routing transit number (RTN) is a bank code that appears in the bottom...
(Discrete Math) A routing transit number (RTN) is a bank code that appears in the bottom of checks. The most common form of an RTN has nine digits, where the last digit is a check digit. If d1d2 . . . d9 is a valid RTN, the congruence 3(d1 + d4 + d7) + 7(d2 + d5 + d8) + (d3 + d6 + d9) ≡ 0 (mod 10) must hold. (a) Show that the check digit of the RTN...
it is a question of discrete math RSA is the most widely used public key cryptosystem....
it is a question of discrete math RSA is the most widely used public key cryptosystem. In this discussion, you will apply RSA to post and read messages. For this reflection discussion, use the prime numbers p = 3 and q = 11. Using the public key e = 3, post a phrase about something that you found interesting or relevant in this course. Include only letters and spaces in your phrase. Represent the letters A through Z by using...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT