Homework 1, Recursion.
Short Description:
Write several recursive functions.
This assignment is worth 40 points.
Goals
When you finish this homework, you should have:
- Designed and implemented several recursive functions.
Formal Description
- [5 points] Design and implement a recursive function to compute ab where b is a non-negative integer.
- [5 points] Using the function from the previous exercise, print a complete version of the following table
Base\Exponent | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
---|
1 | 1 | 1 | 1 | | | | | |
2 | 1 | 2 | 4 | | | | | |
3 | 1 | 3 | 9 | | | | | |
4 | 1 | 4 | 16 | | | | | |
5 | 1 | 5 | 25 | | | | | |
6 | 1 | 6 | 36 | | | | | 279936 |
- The format does not need to match the above, but should be neat and readable.
- All blanks should be filled in.
- [10 points] Design and implement a recursive program to compute Ackermann's Function
- [5 points] Implement a program that computes ackermann's function for all values of m between 0 and 3 inclusive and ll values of n between 0 and 4 inclusive. (See the Wikipedia page for an example table.
- [10 points] Design and implement a recursive function to determine if a string is a palindrome. This should only report that a string is a palindrome if it is exactly the same forward and backward, spaces, case and non-alphabetic characters included.
- [5 points] Implement a program that tests all of the lines in a file to see if they are a palindrome using the function developed in the previous exercise.
Other Requirements
Your code must compile and run on cslab103 without warnings or errors using the following compiler flags
-g -O3 -Wpedantic -Wall -Wextra -Wmisleading-indentation -Wunused -Wuninitialized -Wshadow -Wconversion -D_FORTIFY_SOURCE=2 -std=c++17
Required Files
A single tar file containing the source code, example input files, and a makefile for this program.
If you do not know how to produce a tar file, or need assistance with your Makefile, please contact me.
Submission
Submit your tar file to the D2L folder HW1 by the due date.