edited July 2014 in C and C++
  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.
struct node {
int data;
struct node *next_node;
2. Declare three structures called node1, node2, node3, of type node in the HEAP area of your
3. Your program should 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 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 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
6. 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 );
7. 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 );

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!