CSC 172 - Introduction to Algorithms and Data Structures

Dr. R. M. Siegfried

Assignment #15 - Writing a recusive program.

Due Wednesday, May 7, 2014

Imagine a recursive f(x) defined as:

   f(x) = f(-x)        if x < 0
        = 4*f(x-1) + 3 if x > 1
        = 12           if x = 1
        =  5           if x = 0

Implement f(x), assuming that the parameter and the result are both integer. Write a driver for it that test it with both positive and negative values (at least 4 cases).

[Back to the Assignments List]