Concrete and Abstract Mathematics: Hanoi Tower and Plane Lines, Lecture notes of Computer Science

lectures note discrete mathematics discrete mathematics discrete mathematics discrete mathematics discrete mathematics discrete mathematics discrete mathematics discrete mathematics

Typology: Lecture notes

2015/2016

Uploaded on 09/12/2022

monir-jihad-1
monir-jihad-1 🇧🇩

1 document

1 / 49

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
cse547, math547
DISCRETE MATHEMATICS
Professor Anita Wasilewska
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31

Partial preview of the text

Download Concrete and Abstract Mathematics: Hanoi Tower and Plane Lines and more Lecture notes Computer Science in PDF only on Docsity!

cse547, math

DISCRETE MATHEMATICS

Professor Anita Wasilewska

  • LECTURE

Course Web Page www.cs.stonybrook.edu/˜ cse

The webpage contains:

detailed lectures notes slides;

very detailed solutions to homework problems;

some previous tests;

all to be used for study

Course Text Book

Concrete Mathematics

A Foundations for Computer Science

R. Graham, D. Knuth, O. Patachnik

Course has been taught annually at Stanford University since 1970 and we will follow the book very closely

We use this book for part one of our course

What is Concrete Mathematic? Book Definition

Concrete Mathematics is a controlled manipulation of (some ) mathematical formulas using a collection of techniques for solving problems

We will learn techniques to evaluate horrendously looking sums, to solve complex recurrences, manipulations methods.

The original text of the book was an extension of the chapter ”Mathematical Preliminaries” of Knuth’s classic book ”Art of Computer Programming”

Concrete Mathematics and Abstract (Discrete) Mathematics

Concrete Mathematics (Foundations 1) is supposed (and hopefully will) to help you in the art of writing programs Abstract Mathematics (Foundations 2) is supposed (and hopefully will) to help you to think about the art and correctness of programming

CHAPTER 1

PART ONE: Tower of Hanoi

The Tower of Hanoi

Tower of Hanoi puzzle is attributed to the French mathematician Edouard Lucas, who came up with it in 1883.

His formulation involved three pegs and eight distinctly-sized disks stacked on one of the pegs from the biggest on the bottom to the smallest on the top, like so:

The Tower of Hanoi GENERALIZED

Tower has now n disks, all stacked in decreasing order from bottom to top on one of three pegs,

Question: what is the minimum number of (legal) moves needed to move the stack to one of the other pegs?

Plan:

  1. we start by expressing the minimum number of moves required to move a stack of n disks as a recurrence relation, i.e. find and prove a recursive (recurrent) formula
  2. we find a closed-form formula for the minimum number of moves required;
  3. we prove that the closed-form and recurrent formulas are equivalent

The Tower of Hanoi GENERALIZED to n disks

We denote by

Tn - the minimum number of moves that will transfer n disks from one peg to another under the

L - rule:

must move one disk at a time;

a larger disk cannot be on top of any smaller disks at any time

do it in as few moves as possible

n = 1 - we have 1 disk- and 1 move, i.e. T 1 = 1

n = 2 - we have 2 disks- and 3 moves: top (smaller) disk from

peg 1 to peg 2, remaining (larger) disk from peg 1 to peg 3, the disk from peg 2 (smaller) on the top of the disk (larger) on

peg 3 so L - rule holds and hence T 2 = 3

Recurrent Strategy to evaluate Tn

  1. In order to move the bottom disk, we need to move all the

n − 1 disks above it to a empty peg first

  1. Then we can move the bottom disk to the remaining empty peg, and

3. move the n − 1 smaller disks back on top of it

Recurrent Strategy to evaluate Tn

1. we move all the n − 1 disks above bottom disk to a different

(empty) peg - we do it in Tn− 1 moves;

  1. we move the bottom disk to the remaining empty peg - we do it in 1 moves

3. we move n − 1 disks from peg resulting in 1. to the peg

resulting in 2. - another Tn− 1 moves;

How many moves? together we have at most

Tn− 1 + Tn− 1 + 1 = 2 Tn− 1 + 1 moves i.e we have that

Tn ≤ 2 Tn− 1 + 1 , where n ≥ 1

Recursive Formula for Tn - end of the proof

Observe that in order to move the largest bottom disk

anywhere, we have to first get the n − 1 smaller disks on top

of it onto one of the other pegs.

This will take at least Tn− 1 moves.

Once this is done, we have to move the bottom disk at least once; we may move it more than once!

After we’re done moving the bottom disk, we have to move

the n − 1 other disks back on top of it eventually, which will

take again at least Tn− 1 moves;

all together we get that Tn ≥ 2 Tn− 1 + 1 and hence we proved

our Recursive Formula

Tn =

0 , if n = 0 ;

2 Tn− 1 + 1 , if n > 0.

From Recursive Formula to Closed Form Formula

Often the problem with a recurrent solution is in its computational complexity;

Observe that for any recursive formula Rn, in order to calculate its value for a certain n one needs to calculate

(recursively) all values for Rk , k = 1 ,... , n − 1.

It’s easy to see that for large n, this can be quite complex.

So we would like to find (if possible) a non- recursive

function with a formula f (n),

Such formula is called a Closed Form Formula

Provided that the Closed Form Formula computes the same function as our original recursive one.