CS300 Exam3 - Some Review Questions
1) Using the static list functions, write the code for each of the following queue functions:
a) qCreate
b) qIsEmpty
c) qIsFull
d) qEnqueue
e) qDequeue
2) Consider the following C Definition for a Node
typedef struct NODE *NODE_PTR;
typedef struct NODE
{
int data;
NODE_PTR psNext;
} NODE;
a) Assume that a singly-linked list
is defined as: NODE_PTR psList; Write a recursive function that accepts
a NODE_PTR to a singly-linked list and returns the length (number of
nodes) in the list.
b) Write a function lstDelete that accepts a NODE_PTR and deletes all nodes on the list.
c) Write a function lstLargest that accepts a NODE_PTR and returns the largest data value in the list.
d) Write a recursive function to perform the same function as that described in c).
3) Write a recursive function sumDigits that accepts an integer and
returns the sum of each digit. For example, the statement printf ("%d",
sumDigits (12345)); will print 15 since 1+2+3+4+5 is 15.
4) Write a function that accepts a root pointer psRoot and another
pointer psNode to an arbitrary node in a binary tree. Return a pointer
to the parent of psNode. The function prototype is:
BT_NODE_PTR btParent (BT_NODE_PTR psRoot, BT_NODE_PTR psNode);
5) Draw a picture that shows how a handle works. In particular, using
Activation Records, show how an address actually gets changes through
the use of a handle.
These will get you started. I will try and add more later.