lecture_06_Recursion_2p

lecture_06_Recursion_2p - Lecture 6 Recursion 1 2 3 4 5 6...

This preview shows pages 1–5. Sign up to view the full content.

1 1. Basic reminder on induction 2. Definition of recursion 3 Illustration with the computation of the factorial Lecture 6: Recursion 3. 4. Illustration with Fibonacci numbers 5. The quicksort algorithm 6. Recursive implementation of the quicksort algorithm What is induction? There are some properties which you cannot prove or derive for all cases, but which can be handled sequentially. For example, if you want to prove that the following holds n ( n +1) for all n. First, you would prove a base case, i.e. this relation is true for n=1 (you can check that this is the case). Then you will prove this fact by induction, i.e. you will assume that the property is true up to n, and show that it implies that 1 + 2 + 3 + 4 + · · · + n = 2 the property is true up to n+1. This proves the property by induction.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document