Dale - Computer Science Illuminated 282

Dale - Computer Science Illuminated 282 - 8.3 Functionality...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Recursion The ability of a subprogram to call itself 8.3 Functionality of Imperative Languages 255 Figure 8.7 Difference between value parameters and reference parameters p788 9 –9 1 ###’ , c# ###c , J# uT7Sg 717"’ 717’B r2. .7 2 LD70 , c# g 717"B J# g 717’B r2. .7 2 LD70 , ###’ g 717"B ###c g 717’B By reference By value Recursion When a subprogram invokes itself, the call is known as a recursive call. Recursion —the ability of a subprogram to call itself—is an alternative control structure to repetition (looping). Rather than use a looping state- ment to execute a program segment, the program uses a selection state- ment to determine whether to repeat the code by calling the subprogram again or to stop the process. Each recursive solution has at least two cases: the base case and the general case . The base case is the one to which we have an answer; the general case expresses the solution in terms of a call to itself with a smaller version of the problem. Because the general case solves a smaller and
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/13/2011 for the course CSE 1550 taught by Professor Marianakant during the Fall '10 term at York University.

Ask a homework question - tutors are online