Name (print): ________________________________

Honor Code Acknowledgment (sign): ________________________________________


Random Quiz 2

CPS 100, Fall 1996

6 points

Due: September 12, 1996


All quizzes are due at the beginning of class on the due date.

1. Problem: Count Down (3 points)

Consider the following struct.

struct InfoNode
{
   int key;
   InfoNode * next;
};

Complete the function CountNodes below. Your function should not use recursion.

int CountNodes(InfoNode * list, int value)
// precondition: none
// postcondition: returns the number of nodes > value
{









}

2. Problem: Count Down Again (3 points)

Rewrite CountNodes as a Recursive Function.

int CountNodes(InfoNode * list, int value)
// precondition: none
// postcondition: returns the number of nodes > value
{