LINK LIST - Programmers Heaven

Howdy, Stranger!

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


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.


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 memory.
  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 node1).
  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.