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

Write a test case plan for a typical banking application which involves functionalities like Balance enquiry, deposit, fund transfer etc. Make your assumptions and mention the same in your answer sheet.

1769


how to convert postfix notation into prefix in data structures. please send me algo of taha

2837


what are basic step involved in embedded system software development?

2775


hi friends.... i want do telecom course, iam getting confused. plz tell me courses and levels in that field. iam fresher B.E ECE student. and plz tell institutes in hydrabad or bangalure.

1875


if we give you the job AS A PETROLEUM ENGINEER WHAT WILL YOU DO(that is extraordinary) for our company

3038


Hi i want some previous interview questions and answers for KVB Bank.

2361


A rectangular sheet dimensions a x b is to be made into an open-topped box by cutting a square of side h from each corner and folding the 4 sides up. Find the value of h which allows the maximum volume of the box?

946


Is there any difference between the concepts of encoding,decoding and encryption and decryption?

1839


WAP in Java to print the format AMIT M I T

1809


PLEASE SEND ME NIC SCIENTIFIC OFFICER-2009 EXAM PATTERN AND QUESTION PAPERS

1787


what is the different between view and materialized view in oracle DBA?

1454


Please explain me gsm call scenario for a prepaid roamer calling to a prepaid roamer?

2260


why view is created in database

1448


why every computer should have a boot strap routine?

1619


reverse a number ( like 1234 into 4321) using malloc in C programming

1621