In this problem, you are asked to implement 4 functions:
1. void Create_List(Node**, int);
This function is used to create the linked list according to the input.
2. Node* Delete_Middle_Node(Node*);
This function is used to find the middle node of the linked list, and delete it.
We have to return the processed linked list.
Notice: if the number of integers are even, the middle node should be (n/2)+1 th node.
3. void Print_List(Node*);
This function is used to print out the key value in the linked list.
4. void Free_List(Node*);
This function is used to free the memory space.
Below is correct Create_List function, we implement it for you, you can just copy and paste.
void Create_List(Node** head, int data)
{
if(*head==NULL){
*head = (Node*)malloc(sizeof(Node));
(*head)->data = data;
(*head)->next = NULL;
}
else{
Node* temp = *head;
while(temp->next!=NULL) temp = temp -> next;
Node* new_node = (Node*) malloc(sizeof(Node));
temp->next = new_node;
new_node->next = NULL;
new_node->data = data;
}
}
The input contains one line of several integers.
The line represents a linked list, and each integer is a node of the linked list.
Each line of input is ended by -1, and you don't need to add a new node with key value -1.
It is guaranteed that:
You need to output the linked list which has been through the deletion of middle node.
Each key value is separated by "->".