|
|
 |
|
|
|
|
struct NodeType
{
int info;
PtrType link;
};
PtrType head;
int key; |
|
|
|
 |
|
|
|
|
write a recursive value-returning function that searches a dynamic linked list for the integer value key. If the value is in the list, the function should return a pointer to the node where it was found. If the value is not in the list, the function should return NULL. |
|
|
|
|
|
|
|
|
1. Use recursion to solve the following problem. |
|
|
|
 |
|
|
|
|
A palindrome is a string of characters that reads the same forward and backward. Write a program that reads in strings of characters and determines if each string is a palindrome. Each string is on a separate input line. Echo-print each string, followed by ''Is a palindrome" if the string is a palindrome or "Is not a palindrome" if the string is not a palindrome. For example, given the input string |
|
|
|
 |
|
|
|
|
Able was I, ere I saw Elba. |
|
|
|
 |
|
|
|
|
the program would print "Is a palindrome." In determining whether a string is a palindrome, consider uppercase and lowercase letters to be the same and ignore punctuation characters. |
|
|
|
|
|
|
|
|
2. Write a program to place eight queens on a chessboard in such a way that no queen is attacking any other queen. This is a classic problem that lends itself to a recursive solution. The chessboard should be represented as an 8 Ú 8 Boolean array. If a square is occupied by a queen, the value is TRUE; otherwise, the value is FALSE. The status of the chessboard when all eight queens have been placed is the solution. |
|
|
|
|
|
|
|
|
3. A maze is to be represented by a 10 Ú 10 array of an enumeration type composed of three values: PATH, HEDGE, and EXIT. There is one exit from the maze. Write a program to determine if it is possible to exit the maze from a given starting point. You may move vertically or horizontally in any direction that contains PATH; you may not move to a square that contains HEDGE. If you move into a square that contains EXIT, you have exited. |
|
|
|
 |
|
|
|
|
The input data consists of two parts: the maze and a series of starting points. The maze is entered as ten lines of ten characters (P, H, and E). Each succeeding line contains a pair of integers that represents a starting point (that is, row and column numbers). Continue processing entry points until end-of-file occurs. |
|
|
|
|
|
|
|
|
4. A group of soldiers is overwhelmed by an enemy force. Only one person can go for help because they have only one horse. To decide which soldier should go for help, they put their names in a helmet and put one slip of paper for each soldier with a number on it in another helmet. For example, if there are five soldiers, then the second helmet contains five pieces of paper with the numbers 1 through 5 each written on a separate slip. |
|
|
|
|
|