Arm/linklist del

From ASMBits

In this problem, we will be working with a simple linked list. Each list element only contains a single word that is a pointer to the next node in the list. A pointer with value 0 (null pointer) indicates that the current node is the end of the list.

Write a function that will remove the successor of a given node from the linked list. It does this by changing the next pointer of the given node to point to next->next (skipping over its successor node). To keep the problem simpler, we're removing the successor of the given node rather than the node itself, as it doesn't require searching through the singly-linked list to find a node's predecessor.

If it is not possible to remove the successor node (e.g., the node passed to listdel is null or its successor is null), return null. Otherwise, return a pointer to the node that was removed.

struct node { node *next; };
node* listdel(node* list);

Expected solution length: Around 10 lines.

Sample Input

A -> B -> C -> D-> null

Sample Output

A -> C -> D -> null
returns B

Write your solution here

Upload a source file...