MATH 302 Lecture 14

From Notes
Jump to navigation Jump to search

« previous | Monday, October 17, 2011 | next »


Recursively Defined Sets

Basis step.

Inductive step. if , then .


Example property:

Proof by structural induction.

(1) Basis step.

Inductive step. Assume for . Then and for some .

Hence . THis proves the inductive step, and followl by structural principle of mathematical induction.

(2) Basis step. by definition of

Inductive step. Assume for , then by recursive step definition of . This proves the inductive step and thus the general result follows by the principle of mathematical induction.

Properties of S

Basis step. 3 has a property

Recursive step. If have the property , then has the property

This is an example of structural induction.

Strong Properties of S

Basis Step. Something has a certain property

Inductive Step. Any element which can be obtained either by the basis step or up to iterations for some of recursive step has property . Show any such element that can be obtained by iterations of recursive steps has property .


Trees

Basis step. A root is a tree

Inductive step. Let be disjoint rooted trees such that with corresponding roots . Draw edges connecting another distinct root with each of the roots . , the resulting graph, is a rooted tree.

Example Structural Proof

This proof is for full binary trees in which each node is a leaf or has exactly two children.

Theorem. , where is the number of vertices and is the height.

Proof by Structural Induction.

Basis step. is a root alone: , . true.

Recursive step. Assume and are full binary trees satisfying the theorem


Thus we have for

Adding the two formulae together gives

This proves the inductive step, and the general result follows by the structural principle of mathematical induction.

Q.E.D.


And now for something completely different.

Recursive Algorithms

Solving a problem by reducing it to the same problem with a smaller input.

Simple definition for Factorial

Basis step.

Recursive step. for

def factorial n

 raise Exception.new("must be nonnegative") if n < 0
 return 1 if n == 0
 n * factorial(n-1)

end

Greatest Common Divisor

def gcd a, b

 return b if a == 0
 gcd(b % a, a)

end

Note: if , then a and b are relatively prime.