1. Define a structure called node, which contains an integer element called data, and a pointer to a structure of type node called next_node.
2. Declare three structures called node1, node2, node3, of type node.
3. Write C statements which will link the three nodes together, with node1 at the head of the list, node2 second, and node3 at the tail of the list. Assign the value NULL to node3.next to signify the end of the list.
4. Using a pointer list, of type node, which has been initialised to the address of node1, write C statements which will cycle through the list and print out the value of each nodes data field.
5. Assuming that pointer list points to node2, what does the following statement do?
list->next_node = (struct node *) NULL;
6. Assuming the state of the list is that as in 3., write C statements which will insert a new node node1a between node1 and node2, using the pointer list (which is currently pointing to node1). Assume that a pointer new_node points to node node1a.
7. Write a function called delete_node, which accepts a pointer to a list, and a pointer to the node to be deleted from the list, eg
void delete_node( struct node *head, struct node *delnode );
8. Write a function called insert_node, which accepts a pointer to a list, a pointer to a new node to be inserted, and a pointer to the node after which the insertion takes place, eg
void insert_node( struct node *head, struct node *newnode, struct node *prevnode );
ęCopyright B Brown. 1984-1999. All rights reserved.