Lab-12

Recursion

Announcements

There will be 5 minutes’ quiz available on Blackboard at the beginning of each of the lab session. Please sign in to your Blackboard account and finish the quiz individually. Most of your time should be focused on finishing the lab activity question.

You must work with a single partner i.e., in a group of 2 (If there are an odd-number of students in the class, your TA will make an adjustment). You must take turns being the “driver” and the “navigator” while working on the lab activity.

Lab Grading policy 

You must work with a partner for credit. 

There are 3 stages. The maximum score is 2, where each stage is worth 1 point. Stage 3 is extra credit. To get a grade, you must get graded by the TA in the lab before the lab ends. TAs will not be grading after the 50 minutes of the lab session are over. Once you finish your work, please raise your hand and show your work to the TA during the last 10 minutes of lab or whenever you finish, the earlier of the two.

Lab Activity

You are required to implement three functions to practice three different example of recursion, of progressing complexities. You will take functions that work non-recursively, and you will rewrite them to work recursively. A driver code has been provided for this activity for you to get started. In order to complete these functions, you should review and have a firm knowledge about recursion.

Stages You Need to Do

Problem 1 (1 point) : 

Display odd numbers less than some limit. Complete the function problemOneOddNumbersRecursive given in the .cpp file below.

Problem 2 (1 point) :

Count the number of upper-case letters in an array. Complete the function problemTwoCountUpperRecursive given in the .cpp file below. You are free to change the parameter of the function. And do whatever you think necessary to make it in recursive version. 

Problem 3 (Extra credit) :

Reverse a string of characters. Complete the function problemThreeReverseRecursive given in the .cpp file below. You are free to change the parameter of the function. And do whatever you think necessary to make it in recursive version. 

For your convenience, a driver code is attached (Lab12DriverCode.cpp). However, feel free to write your own code, as long as it works the way it is described above.