You are given a pointer to the middle node of a singly linked list. Delete that node.
Each node of a singly linked list contains, in addition to the information concerning its subject matter, a pointer to the next node on the list.
Use the pointer you already have to retrieve the pointer on the node that's to be deleted. You will use that pointer twice: the first time to copy that next node into the memory occupied by the node to be deleted; the second time to free up the memory previously occupied by that node that you moved away to take the place occupied by the deleted node.
|
Posted by Charlie
on 2021-05-31 09:20:21 |