http://www.cs.wpi.edu/~cs2301/common/lab5.zip
If you now list the files in your directory, you should see entries for linktool.h, linktool.c, and linktest.c.
linktool.c
and linktest.c
contain these include
directives:
linktool.c #include "linktool.h" linktest.c #include "linktool.h"Using this information, create a makefile to generate an executable program called linktest. Compile your program by running make.
lists_are_equal()
in linktool.h
.
What does it mean for two lists to be equal? We will define equality
to mean that
You need to write the function lists_are_equal()
and put your solution
in linktool.c
(you will find a stub for the function at the end of linktool.c
). Your solution must be recursive.
You should define the base cases first (the cases that will stop the
recursive calls and return 1 (true) or 0 (false) to the calling function).
What are the base cases for lists_are_equal()
? There are three of them:
Once you have defined the base cases, you should then define the general (recursive) case. Remember, you want each successive recursive call to reduce the "size" of your problem.
linktest
. Run the test program to see if your function works correctly.
There's no lab next week (April 17) - enjoy the shortened week. Lab 6 will be given on Wednesday, April 24.