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

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

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 Databases Questions!