Assignment #5 – (100 points) Solution




• Answer the questions individually. Group effort is not allowed.

• Solutions must be committed to your respective repositories on github.

• For this assignment, you are not allowed to use any library functions not declared in stdio.h.

• Ensure that your code runs on

• Prototypes must be provided for all functions within the header file define.h.

• Code must be appropriately commented.

• Useful resources:

– Common linux commands:



1.(100points)Youaretoimplementafunction:Node *my reverse(Node

*head) that reverses a list beginning at Node *head. The return value of

this function is a pointer to the head of the newly-reversed linked list. A linked

list is a collection of Nodes that are connected to each other using pointers. The last node in a list points to NULL.

The following definition of a Node is provided in define.h, and may not be modified in your submission:


struct _Node {

union {

} val;

int n;

char c;

void *ptr;

int var;


typedef struct _Node Node;