Question: IN C PROGRAMMING Recall that recursion involves the use of a function the calls itself directly or indirectly through a sequence of calls. Problems that
IN C PROGRAMMING
Recall that recursion involves the use of a function the calls itself directly or indirectly through a sequence of calls. Problems that are best suited for recursive solutions have the following properties or characteristics:
Task:
1a. Complete Project 2 in Chapter 9 on page 568 of Hanly & Koffman Problem Solving and Program Design in C. A palindrome consists of a word or deblanked, unpunctuated phrase that is spelled exactly the same when the letters are reversed. Write a recursive function that returns a value of 1 if its string argument is a palindrome. Notice that in palindromes such as level, deed, sees, and Madam I'm Adam (madamimadam), the first letter matches the last, the second matches the next-to-last, and so on.
b. Complete Project 5 in Chapter 9 on page 568 of Hanly & Koffman Problem Solving and Program Design in C. Write a function that accepts an 8 by 8 array of characters that represents a maze. Each position can contain either an X or a blank. Starting at position (0, 1), list any path through the maze to get to location (7, 7). Only horizontal and vertical moves are allowed. If no path exists, write a message indicating there is no path.
Moves can be made only to locations that contain a blank. If an X is encountered, that path is blocked and another must be chosen. Use recursion.
c. Complete Project 7 in Chapter 9 on page 569 of Hanly & Koffman Problem Solving and Program Design in C. Write a recursive function that displays all the binary (base 2) numbers represented by a string of xs, 0s, and 1s. The xs represent digits that can be either 0 or 1. For example, the string 1x0x represents the numbers 1000, 1001, 1100, 1101. The string xx1 represents 001, 011, 101, 111. Hint: Write a helper function replace_first_x() that builds two strings based on its input argument. In one, first x is replaced by a 0, and in the other by a 1. The set function is_element() may be useful too.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
