Name (print): ________________________________

Honor Code Acknowledgment (sign): ________________________________________


Random Quiz 3

CPS 100, Fall 1996

6 points

Due: September 24, 1996


1. Problem: Sticky Stamps (2 points)

Prove by induction that any integer postage greater than 7 cents can be formed using only 3-cent and 5-cent stamps.





2. Problem: Double Trouble (4 points)

For this problem, write a function called DoubleList to replace a linked list with a list that has two copies of each item in the original list, the two identical items should be adjacent.

For example, consider the following list:

DoubleList(list) would convert the list to:

Let each item in the list be represented by the struct Node:

struct Node
{
   string name;
   Node * next;

   Node(string n, Node * ptr = 0)
   {
      name = n; next = ptr;
   }
};