Question: Lab Exercise There are two Parts to this exercise. In the first part, you will answer questions related to the code given in Section 2

Lab Exercise
There are two Parts to this exercise.
In the first part, you will answer questions related to the code given in Section 2.
In the second part, you will download the functioning code and implement additional recursive functions.
Part 1
Answer the following questions:
Although, it is not explicitly stated, what is the base case for writeSub()?
What is the base case for insertEndSub()?
If you wanted to print the list backwards, how would you modify writeSub()? Why?
Part 2
Get the files:
recursion.cpp
listrec.h
There are two files used in this program:
listrec.h contains the implementation of the linked list class
recursion.cpp -- the main program. This contains the calls to test the linked list member functions. Including the recursive ones.
Your primary tasks for this exercise are:
Alter the writeSub() function so that it prints the list in reverse.
Steps include:
Try to run this program. You should get the prompt:
Enter a list of characters :
Now, type "abc" and enter. You will get the following output:
Enter a list of characters : abc
a b [c]
List : abc
List : abc!
a b c [!]
Press any key to continue
Now, modify the writeSub() function (in the listrec.h file) so that it prints in reverse. Build and Run your program, you should get the following output:
Enter a list of characters : abc
a b [c]
List : cba
List : !cba
a b c [!]
Press any key to continue
Next, create a new recursive function that will insert the character 'a' immediately before each occurence of the character 'b'. The cursor will not change.
add code in the listrec.h file for aBeforeb() and aBeforebSub(). The function prototypes exist, you have to add code to get them running.
Build and run the executable.
Your output will look like this:
Enter a list of characters : abc
a b [c]
List : cba
List : !cba
a a b c [!]
Press any key to continue
Prepare a test plan for this function that includes list containing the character 'b' at the beginning, middle, and end. A test plan form follows.
Execute your test plan. If you discover mistakes in your implementation of the aBeforeb() function, correct them and execute your test plan again.
Test Plan for the aBeforeb Operation
Test Case List Expected Result Checked
b in beginning
b in middle
b at end
multiple b's
When you are finished, your program should:
Insert the char 'a' before any 'b' in the input without getting stuck
If there are multiple 'b's, your program must insert multiple 'a's
Your program must not drop or lose other parts of the input
An example run could look like this:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!