Given a pointer that points to an intermediate node (non-head, non-tail) on a single-link list . How to insert a new node just before the node pointed to by the given pointer ?
Example,
Given single-linked list:
A -> B -> C -> D -> E
Given a pointer pointed to C (ptr = &C), and a new node F, how to get
A -> B -> F -> C -> D -> E
Attention: we do not have pointers pointed to A.
Thanks
You should be able to implement this by inserting a new C node to the right, and writing F in the data field of the initial C node.