Name: ________________________________
Honor Code Acknowledgment: ___________________
Describe what list represents after the call
list = Build(7); where the function Build
is defined below.
What is the value of the expression DoWhat(10); where the
function DoWhat is given below.
Problem 1 rec.list.linked: (2 points)
struct Node
{
int info;
Node * next;
};
Node * Build(int num)
// postcondition: returns a linked list ????
{
if (0 == num)
{
return 0;
}
else
{
ListNode * temp = new Node;
temp->info = num;
temp->next = Build(num - 1);
return temp;
}
}
Problem 2 C. F. Gauss: (2 points)
int DoWhat(int num)
// postcondition: returns a number ???
{
if (0 == num) return 0;
else return num + DoWhat(num - 1);
}