Question: 10. Given the NodeObj structure and Node reference from problem 9 above, write the following C functions: a. A constructor that returns a reference to
10. Given the NodeObj structure and Node reference from problem 9 above, write the following C functions:
a. A constructor that returns a reference to a new NodeObj allocated from heap memory with its item field set to x and its next field set to NULL.
Node newNode(int x){
// your code goes here
}
b. A destructor that frees the heap memory associated with a Node, and sets its reference to NULL.
void freeNode(Node* pN){
// your code goes here
}
c. A recursive function with heading void clearList(Node H) that frees all heap memory associated with a linked list headed by H.
void clearList(Node H){
// your code goes here
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
