Linked lists programming in c - insert a new list node with


Linked Lists Programming in C -

Insert a new list node with the given value right after the specified node.  The next pointer of the head node should point to the new node, and the next pointer of the new node should point to the old next pointer of the head node.

Use alloc_node to create a new node. Don't forget to set its value!

Return a pointer to the last node in a linked list, starting from the given head node.  If the list only consists of the head node (i.e. the head node's next pointer is null), then simply return the head node pointer.

If the head node pointer refers to the node with the value 0, list_end(head) should return a pointer to the node with the value of 2.

Return the number of nodes in a linked list, starting from the given head pointer.  Since the head pointer is always non-null, the size of a list will be at least 1.

If the head node pointer refers to the node with the value 0, list_size(head) should return 3.  If the head node pointer refers to the node with the value 1, list_size(head) should return 2.

Return a pointer to the first node in the given linked list (starting at head) with the specified value, and store the pointer to its predecessor node at predp.  If no such node exists, return NULL and set the predecessor to NULL as well.

If the head pointer refers to the node with the value 0, and predp points to a local struct list_node pointer variable, then a call to list_find(head, 2, predp) should return a pointer to the node with the value of 2 and the predecessor pointer should point to the node with the value of 1.

If the head node contains the sought-after value, then the predecessor pointer should be set to NULL.

Remove a node from the given linked list (starting at the given head) with the specified value.  Return 1 if a node was removed and 0 otherwise.  If the node removed is the head node, then set the pointer to the head pointer to point to the new list head (which should be head->next).  Use free_node on the removed node.

Note that instead of a pointer to a node, the passed head pointer "headp" is actually a pointer to a pointer.  To get the pointer to the head node, you will need to dereference it.  A pointer to a pointer is passed so that the value of the head node pointer can be changed if the head node is removed.

Attachment:- Assignment File.rar

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: Linked lists programming in c - insert a new list node with
Reference No:- TGS02655846

Expected delivery within 24 Hours