Induction and Recursion. CSC-2259 Discrete Structures. Induction. Induction is a very useful proof technique. In computer science, induction is used to prove properties of algorithms. Induction and recursion are closely related. Recursion is a description method for algorithms
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation
Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement.Téléchargez la présentation en cliquant sur ce lien.Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.
Induction Induction is a very useful proof technique In computer science, induction is used to prove properties of algorithms Induction and recursion are closely related • Recursion is a description method for algorithms • Induction is a proof method suitable • for recursive algorithms Konstantin Busch - LSU
Use induction to prove that a proposition is true: Inductive Basis: Prove that is true Inductive Hypothesis: Assume is true (for any positive integer k) Inductive Step: Prove that is true Konstantin Busch - LSU
Inductive Hypothesis: Assume is true (for any positive integer k) Inductive Step: Prove that is true In other words in inductive step we prove: for every positive integer k Konstantin Busch - LSU
Inductive basis Inductive Step True True Proposition true for all positive integers Konstantin Busch - LSU
Strong Induction To prove : Inductive Basis: Prove that is true Inductive Hypothesis: Assume is true Inductive Step: Prove that is true Konstantin Busch - LSU
Theorem: Every integer is a product of primes (at least one prime in the product) Proof: (Strong Induction) Inductive Basis: Number 2 is a prime Inductive Hypothesis: Suppose that every integer between and is a product of primes Konstantin Busch - LSU
Inductive Step: If is prime then the proof is finished If is not a prime then it is composite: Konstantin Busch - LSU
Theorem: Every postage amount can be generated by using 4-cent and 5-cent stamps Proof: (Strong Induction) Inductive Basis: We examine four cases (because of the inductive step) Konstantin Busch - LSU
Inductive Hypothesis: Assume that every postage amount between and can be generated by using 4-cent and 5-cent stamps Inductive Step: If then the inductive step follows directly from inductive basis Konstantin Busch - LSU
Consider: Inductive hypothesis End of Proof Konstantin Busch - LSU
Recursion Recursion is used to describe functions, sets, algorithms Example: Factorial function Recursive Basis: Recursive Step: Konstantin Busch - LSU
Recursive algorithm for factorial factorial( ) { if then return else return } //recursive basis //recursive step Konstantin Busch - LSU
Fibonacci numbers Recursive Basis: Recursive Step: Konstantin Busch - LSU
Recursive algorithm for greatest common divisor gcd( ) { if then return else return } //assume a>b //recursive basis //recursive step Konstantin Busch - LSU
Lames Theorem: The Euclidian algorithm for , uses at most divisions (iterations) Proof: We show that there is a Fibonacci relation in the divisions of the algorithm Konstantin Busch - LSU
remainder divisions first zero result Konstantin Busch - LSU