next up previous contents
Next: Dynamically Allocated Memory and Up: Recursion Previous: Demystifying Recursion   Contents

Assignment (Extra Credit 200 Points)

In this assignment, you have to implement binary search recursively. Refer to section 15.2 for the iteration version.

Define your binsrch to have the same interface as the one in section 15.2. In other words, it should have the same parameters and return type. However, your version (recursive) should not have any loop.

To test your subroutine, you can either hardcode and initialize the elements in the array or write a small subroutine to read values into the array. The choice is yours. I reserve the right to change your hardcoded values to fully test the functionality of your recursive subroutine.

For testing purposes, don't put too many elements into the array. Try 7 or even 3. Make sure the array is sorted non-decreasingly. Make sure that you can search all the values in the 7-element or 3-element array and report all values that do not exist in the array as missing.

The due date is two weeks after the assignment date. No late work is accepted on and after the first day of finals.


next up previous contents
Next: Dynamically Allocated Memory and Up: Recursion Previous: Demystifying Recursion   Contents
Tak Auyeung 2003-12-03