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

Answer Posted / hasan ali mirza

list reverse(list L)
{
stack S;
position Lpos = first(L);
while(Lpos->element != NULL)
{
push(Lpos->element, S);
Lpos = Lpos->next;
}
makeEmpty(L);
Lpos = first(L);
while(isempty(S) == FALSE)
{
insert(pop(S), Lpos);
Lpos = Lpos->next;
}
return L;
}

Is This Answer Correct ?    3 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is major differnet between hub and switch and also defferent between router and switch

1695


Please state briefly the reasons why you think you are an outstanding candidate for this job

12598


Hi, I am preparing for Assistant Motor Vehicle Inspector (AMVI) exam.If any body having old question papers please send.My mail id is siyadndd@gmail.com

1980


Difference between software process model and software process.?

1757


searching a B-tree indexed tree compared to B+ tree is slow..True or false

2092


Please help to write testcase for ECG machine

1693


i can access command prompt in my pc. when i type cmd in run,message comes-you are restricted.contact admin. why is it so? how can acces it by just logging in as a user and not as admin.?????

1784


What is Lease Line?Why power cord is not required to NT Boxex on which lease is connected ?Why we use use NT BOXEs for ISDN and Lease line?

1724


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?

3466


There are n points and each point enclose with x and y axis form a rectangle and find the point using a program which forms the smallest rectangle?

1715


when does the official confirmation or the offer letter for the 2012 selected candidates of HUAWEI will come??

1708


why view is created in database

1494


Hello everybody, I have applied for the AAI jr executive ATC exam. I am from CSE branch. Is Exam paper for the CSE and other branches same or not? Because I don't have knowlwdge on Electronic subject? Can any one please send me the previous exam papers for AAI Jr Executive of CSE branch My id is: naveen.kocherla@gmail.com Thanks and Regards Naveen

2207


how will u recieve idoc

1792


which is the better form java or .net?exactly when we have to choose particcular 1 among them?

1592