HW3 - HW3 Recursion Due: Friday, September 12, 2008 at...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
HW3 Recursion Due: Friday, September 12, 2008 at 11:59pm Assignment Overview =================== This assignment serves to reinforce the recent lectures on recursion (also found in section 3.5 of the textbook). In this assignment you will trace a few recursive methods and then write some recursive methods of your own. Part 1: Tracing =============== You will be asked to trace two recursive methods using a variety of inputs. First though, we have provided an example (as well as an acceptable solution) so you know what we are looking for. A sample question might look as follows: int example(int arr[], int n) { if (n==0) return 0; else { int smallResult = example(arr, n - 1); return smallResult + arr[n-1]; } } Write the resulting trace, making sure to state what the value of returnValue will be once execution is complete. a. Assume that the call is as follows: int[] exArray = {1, 2, 3, 4}; int returnValue = example(exArray, 4); A solution for the above question might be as follows: example([1, 2, 3, 4], 4) smallResult = example([1, 2, 3, 4], 3) smallResult = example([1, 2, 3, 4], 2) smallResult = example([1, 2, 3, 4], 1)
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/13/2008 for the course CS 1332 taught by Professor Lebanon during the Spring '08 term at Georgia Institute of Technology.

Page1 / 3

HW3 - HW3 Recursion Due: Friday, September 12, 2008 at...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online