CMPT 115 Lecture Notes - Lecture 11: Linked List, Memory Address
Document Summary
Notes written by michael horsch, mark eramian, ian mcquillan, lingling jin, and dmytro dyachuk. 2. 4 some hints and rules of thumb . Dispelling concerns about recursion: recursion is a form of repetition based on function calls, instead of loops, you may like loops better because you practice those more. Understanding relationships is what humans do best. Therefore, recursion is what humans do best. Recursion: de nitions that refer to themselves are said to be recursive , example: n! Recursive algorithms: recursive algorithms (or c functions) are those that call themselves, recall that each time a recursive call is made, that call gets its own copy of local variables. Return: returns n! if ( n = 0 ) then return 1 else return n * factorial(n-1) // returns n! assuming n >= 0 int factorial (int n) { if( n == 0 ) { return 1; else { return n * factorial(n-1);