Reversing the second half of the linked list
| 87 | |
| 88 | //Reversing the second half of the linked list |
| 89 | void reverse(struct Node** head_ref) |
| 90 | { |
| 91 | struct Node* prev = NULL; |
| 92 | struct Node* current = *head_ref; |
| 93 | struct Node* next; |
| 94 | |
| 95 | //Run a loop for reversing the linked list |
| 96 | while (current != NULL) { |
| 97 | next = current->next; |
| 98 | current->next = prev; |
| 99 | prev = current; |
| 100 | current = next; |
| 101 | } |
| 102 | *head_ref = prev; |
| 103 | } |
| 104 | |
| 105 | //Comparing the first and the second half of the linked list |
| 106 | bool compareLists(struct Node* head1, struct Node* head2) |