Question: / / * * * / / * * * You MUST modify this file / / * * * #include #include #include #include #include
You MUST modify this file
#include
#include
#include
#include
#include hwh
DO NOT MODIFY this function
void printListNodeListNode head
ListNode p head;
printfprintListNode: ;
while p NULL
printfd p value;
p p next;
printf
;
until here
create a linked list storing values valn
The first node head stores the next node stores
the last node stores valn
return the head of the linked list
ListNode createListint valn
return NULL;
eliminate the nodes in the linked list
starting from the head, move one node at a time and count to valk.
eliminate that node, keep counting
when reaching the end of the list, continue from the beginning of
the list
print the values of the nodes to be deleted
void eliminateListNode head, int valk
#ifdef DEBUG
this #ifdef #endif should be inside the condition BEFORE a
node' value is printed and it is deleted
ListNode todelete p;
printListNode todelete;
#endif
head points to the first node in the linked list
todelete points to the node to be deleted
delete the node and return the head of the linked list
release the memory of the deleted node
should check several conditions:
If head is NULL, the list is empty and this function returns
NULL
If todelete is NULL, nothing can be deleted, return head
If todelete is not in the list, keep the list unchanged and
return head
It is possible that todelete is the first node in the list ie
the head If this occurs, return the second node of the list.
ListNode deleteNodeListNode head, ListNode todelete
return NULL;
expected output:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
