Question: The following function is a member function in singly linked list class. The function is called with the list containing the integers 1,2,3,4,5,6,7 in the

The following function is a member function in singly linked list class. The function is called with the list containing the integers 1,2,3,4,5,6,7 in the given order. What will be the contents of the list after the function completes execution? struct node Type{ int info; node* next; }; void doSomething () { node Type *p,*q; int temp; if (head != NULL && head->next != NULL) { p=head; q=head->next; while(p!=NULL && q !=NULL) { temp=p->info; p-> info =(q-> info); q-> info =temp-1; p=q->next; q=p->next; }// End of while loop // End of if }//End of doSomething function 2, 1, 4, 3, 6, 5, 7 7, 7, 6, 5, 4, 3, 2 2, 0, 4, 2, 6, 4,7 3,2,5, 4, 7, 6,7
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
