Question: The following function rearranges the elements of the single-linked list of integers. The function is called with the list containing the integers 3,2,5,4,7,6, 1 in

The following function rearranges the elements of the single-linked list of integers. The function is called with the list containing the integers 3,2,5,4,7,6, 1 in the given order. What will be the contents of the list after the function completes execution? Given the node definition is as following struct node int data; node *next; } void list::rearrange(( ) |{ node *P, q; int temp; if ((head) || Thead ->next) return; P = head; 9 = head ->next; while(a) { temp - p->data; p->data = q ->data; q->data - temp; P = q ->next; qp?p->next:0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
