Write a nonrecursive routine to reverse a singly linked
list in O(N) time.

Answer Posted / sandeep

node * reverse(node * list)
{
node *p, *q, *r;
p = list;
q = p->next;
while(q->next != NULL)
{
q = p->next;
r = q->next;
p->next = r;
q->next = p;
p = p->next;
}
q->next = p;
p->next = NULL;
return q`;
}

Is This Answer Correct ?    26 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

describe what is const pointer and why do we need it?

1528


HOW WE CAN CORRELATE THE MA\ECHANICAL POWER TO ELECTRICAL POWER. SUPPOSE IF I WANT A PUMP OF PUMPIG 200 LPM AT 20 METER HEAD MENAS WHAT IS THE POWER NEEDED FOR PUMP IN ELECTRCAL AND HOW CAN WE GET IT

1392


what is locative information on web.........?

1388


W.A.P to take input of an array and display the entered no. in dos.

1592


What is Mointer in Operating System?

1263






different types of protocols.......?

1434


how you judge that your interview go good????

1484


why we select you?

1776


Please send me the ongc old question papers

2627


what is the difference between VARCHAR and VARCHAR2?

21438


WHAT IS THE NAMESPACE FOR CUSTOMCONTROL AND USER CONTROL IN ASP.NET?

1654


Suppose that, even unrealistically, we are to search a list of 700 million items using Binary Search, Recursion (the algorithm given in class). What is the maximum number of comparisons that this algorithm must perform before finding a given item or concluding that it is not in the list?

3240


How does agile communication differ from tradition software engineering communication? How it is similar?

3511


What is ball bearing concept & its design.

1426


what is the difference between composite key and primary key in sap abap

2118