Question: / / * * * / / * * * You MUST modify this file / / * * * #include #include #include #include #include

//***
//*** You MUST modify this file
//***
#include
#include
#include
#include
#include "hw10.h"
// DO NOT MODIFY this function --->>>
void printListNode(ListNode* head)
{
ListNode* p = head;
printf("printListNode: ");
while (p != NULL)
{
printf("%7d ", p -> value);
p = p -> next;
}
printf("
");
}
//--- until here
// create a linked list storing values 0,1,2,... valn -1
// The first node (head) stores 0, the next node stores 1,
//..., the last node stores valn -1
// return the head of the linked list
ListNode* createList(int 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 eliminate(ListNode* 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:
//1. If head is NULL, the list is empty and this function returns
// NULL
//2. If todelete is NULL, nothing can be deleted, return head
//3. 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 (i.e.,
// the head). If this occurs, return the second node of the list.
ListNode* deleteNode(ListNode* head, ListNode* todelete)
{
return NULL;
}
expected output:
/ / * * * / / * * * You MUST modify this file / /

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!