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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started