Outline of the Lecture 20

November 16, 2000

Section 3.4  Recursive Algorithms


Problem of finding of gcd(a,b) with a < b can be reduced to finding of gcd(b mod a, a) since 
                               gcd(a,b) = gcd(b mod a, a).
Therefore, the solution to the original problem can be found with a sequence of reductions, until
the problem has been reduced to some initial case for which the solution are known.
In the case of gcd(a,b) - until obtaining the problem of finding gcd(r,0) with r > 0.

Definition 1  An algorithm is called recursive if it solves a problem by reducing it to an instance 
                     of the same problem with smaller input.

Recursive version of the Euclidean algorithm is given in Example2.  As we can see, in a recursive 
algorithm we call a procedure from its inside, i.e. a procedure calls itself.
Example 4 gives the recursive version of the binary search algorithm.


A recursive algorithm is an algorithm that proceeds by reducing a problem to the same problem 
with smaller input.
An iteration is a procedure based on the repeated use of operations in a loop.

Analyze Algorithms 5 and 6 to understand the difference between an iterative algorithm and a
recursive algorithm.
Go over Algorithms 7 and 8 to compare and contrast the iterative and recursive approaches
to computing Fibonacci numbers.


Outline of the Lecture 19

November 08, 2000

Section 3.3  Recursive Definition



    Inductive or recursive definition of a function defined on the set of nonnegative integers.
    How to define factorial function f(n) = n! recursively - see Example 2.
    Why recursively defined functions and sequences are well defined?

    Definition of Fibonacci numbers  - Example 5.
    The important property of Fibonacci numbers is given in Example 6.
    Prove this property by the second principle of mathematical induction.

    Lame's Theorem: Let a and b be positive integers with a >= b. Then the number of divisions used by
  the Euclidean algorithm to find gcd(a,b) is O(log b).

        The proof of Lame's Theorem is strongly based on the inequality established in Example 6. 


    How to use inductive (recursive) definitions to define sets.
    Go over Example 8.

    How well-defined formulae are defined.
    See Example 8 or 9.

    Recursive definitions and study of strings.
    Recursive definition of the set of strings over given alphabet (Example 12).


Outline of the Lecture 18

October 27, 2000

Section 3.2  Mathematical Induction


THE WELL-ORDERING PROPERTY (AXIOM) of the set of integers


            Steps of a proof by induction:

                        Base Case: Prove P(1) is true

                        Induction Hypothesis: Assume P(k) is true for any arbitrary chosen

positive integer k

Induction Step: Prove that P(k+1) must also be true.

Conclusion: P(n) is true for all positive integers n           

            Hence, a proof by mathematical induction consists of two steps:

1.      Basis step: The proposition P(1) is shown to be true.

2.      Inductive step: The implication P(k) P(k+1) is shown to be true for every positive integer k. 

Why is mathematical induction a valid proof technique?
Prove that by using the well-ordering property. 

Note that mathematical induction can NOT be used to find formulae or to formulate theorems, but
can be used to prove that a formula or theorem is correct.

To learn how to prove equalities and inequalities by mathematical induction see Examples 2, 3, and 10. Also, see Examples 4, 8, 11, and 12. 

                        1.      Basis step: The proposition P(1) is shown to be true.

2.      Inductive step: The implication [P(1)&P(2)& ... &P(k)] P(k+1) is shown to be true for every positive integer k.   

            How to prove theorems using the second principle of mathematical induction?
            Go over the Example 13, which proves that every positive integer is a product of
         primes (do base case for the integer 2 instead of the integer 1, since 1 is not a prime number).

            Note that this example proves the existence part of the Fundamental Theorem of Arithmetic and thus, completes the proof of the
         Fundamental Theorem of Arithmetic.