//This is the implementation file // It implements the functions in the header file #include #include #include "linked_list.h" //Define a node struct node { int data; struct node *next; }; //Function that creates a node // TODO: Fill in input and output to complete function struct node *create_node(int data, struct node *next) { //TODO: create a pointer to a node of type struct node //by using malloc to allocate memory //(4, NULL) // new_node = some address that points to that node //(2, head) struct node *new_node = malloc(sizeof(struct node)); //TODO: Initialise the data by setting it to the given int //new_node (int data) = 4 //new_node (int data) = 2 new_node->data = data; //TODO: Initialise next pointer to point to the next node given //new_node (struct node *next) = NULL // new_node(struct node *next) = head (4) new_node->next = next; //TODO: What will I need to return? return new_node; } //Function that prints a list // TODO: Fill in input and output to complete function void print_list(struct node *head) { //TODO: create a way to keep track of where we are in the list struct node *current = head; //TODO: What will be the condition where our while loop can stop while (current != NULL) { //TODO: print out the node value printf("%d -> ", current->data); //TODO: increment to the next node current = current->next; } //Finish printing list with an X printf("X\n"); }