Name: ________________________________
Honor Code Acknowledgment: _____________________________
Due: October 29
A doubly linked list is represented using the following Node definition (Assume the "ends" of the list are set to NULL, that is, the next field of the rightmost node in the list is NULL and the prev field of the leftmost node in the list is NULL).
struct Node
{
int data;
Node * next;
Node * prev;
};
int Mystery(Node * list)
{
if (list == NULL)
return 0;
else
return 1 + Mystery(list->next) + Mystery(list->prev);
}
int Mystery2(int n)
{
if (n <= 1)
return 0;
else
return 1 + Mystery2(n/2) + Mystery2(n/4);
}