What will be the contents of the list after the function completes - ProProfs Discuss
Topics-
Products +
     

What will be the contents of the list after the function completes execution?



The following C Function takes a singly- linked list of integers as a parameter and rearrangesthe elements of the lists. The function is called with the list containing the integers 1,2,3,4,5,6,7 in the given order.

struct node{int value;struct node* next;};void rearrange (struct node* list){struct node *p,q;int temp;if (! List || ! list->next) return;p->list; q=list->next;while(q){temp=p->value; p->value=q->value;q->value=temp;p=q->next;q=p?p->next:0;}} 

A. 1, 2, 3, 4, 5, 6, 7
B. 2, 1, 4, 3, 6, 5, 7
C. 1, 3, 2, 5, 4, 7, 6
D. 2, 3, 4, 5, 6, 7, 1

This question is part of 15IT32C - Data Structures and Algorithms - Multiple Choice Test
Asked by Rmkumar, Last updated: Apr 04, 2018

+ AnswerRequest Answer
...

1 Answer

rmkumar

Rmkumar

Answered on Apr 03, 2018

2, 1, 4, 3, 6, 5, 7
 Reply

Search for Google images
Select a recommended image
Upload from your computer
Search for Google images
Select a recommended image
Upload from your computer
Search for Google images
Select a recommended image
Upload from your computer

Email Sent
We have sent an email to your address "" with instructions to reset your password.