CSE 221 Lab 6
- Familiarity with using Text objects and operations.
- Familiarity with developing recursive implementations of operations.
The problem is to implement and test four different recursive
implementations of the Swap_Substring operation. Each
implementation is to be developed using the five-step process discussed
in the "Getting Started" notes. The last section of this document, Four Visualizations of Recursive Structure, provides
four different figures for step 1. Each figure visualizes recursive
structure in a different way leading to four different implementations
of Swap_Substring. Your task is to provide these four
implementations. Note that the first implementation must correspond
to Figure 1, the second implementation to Figure 2, and so on.
Set Up
- In an xterm window, create a new directory (folder) for this lab by
typing the "make directory" command:
mkdir lab06
- Change or move to the new directory (folder) for this lab by
typing the "change directory" command:
cd lab06
- Copy the catalog for this lab by typing the "copy" command:
cp -R /class/sce/now/221/labs/catalogs/lab06/* .
NOTE: The period . is part of the command. It denotes the current directory (folder).
This copy command will copy recursively (because of the -R) all the files
and directories from the shared class directory into your directory, effectively
duplicating the entire substructure from the class directory into your
directory.
- To see what was copied, type the "list" command:
ls
You should see four directories: swap1, swap2, swap3,
and swap4. Directory swap1 contains two files:
- Swap_Substring_Test_1.cpp
- test-script
Each of the other three directories will be empty. test-script is the
test-script file from Closed Lab 6. Swap_Substring_Test_1.cpp is
the usual test driver for Swap_Substring in need of an implementation
of Swap_Substring.
- Copy Swap_Substring_Test_1.cpp and test-script
from directory swap1 into each of the other three "swap"
directories in your lab06 directory.
In the swap2 directory, name the test driver
Swap_Substring_Test_2.cpp, in swap3 name it
Swap_Substring_Test_3.cpp, and so on.
- Fill in the procedure body for Swap_Substring in
Swap_Substring_Test_1.cpp through Swap_Substring_Test_4.cpp.
In Swap_Substring_Test_1.cpp, provide an
implementation based on Figure 1, in
Swap_Substring_Test_2.cpp
provide an implementation based on Figure 2, and so on.
- Test each of your implementations of using
the test-script file test-script.
Once you are convinced that your implementations are
working correctly, submit the files
- Swap_Substring_Test_1.cpp
- Swap_Substring_Test_2.cpp
- Swap_Substring_Test_3.cpp
- Swap_Substring_Test_4.cpp
You should use the submit command to turn in these files.
If you have followed the above
instructions for naming files, then the easiest way to do this is with
the following submit command, issued when you are in your lab06
directory:
submit c221xx lab06 */*.cpp
where "xx" is to be replaced by lower case letters
designating your section (see the course home page for a list).



