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

I have file with input as below : Name Value Rohan 12,13,14 Rohit 1,2,3 Output should be : Rohan 12 Rohan 13 Rohan 14 Here how will the normalize component work? Thanks

1177


objective type quistion

2512


What is the pressure in co2 cartridge in a DCP 5 kg extinguisher.

3077


postfix expression for x^y^z-m+n+p/q ?

1972


Tell me about urself? asked me qstns on my resume what about higher studies any plans? where do u find urself after 3-4

1906


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

2278


If you were to drill a circular hole in a sheet of metal and then heat the sheet, what would happen to the size of the hole?

890


I an doing Engineering in IT(4th year). i want to know what is the scope or .NET and Linux, and which is better for carrier

1603


I am getting the following error,when I am running the script, Cannot identify the specified item of the regions object. Confirm that the specified item is included in the object's item collection. My Script: Itemname=Browser("MLSListings.com").Page ("MLSListings.com").WebList("regions").GetItem(i+1) Print Itemname Browser("MLSListings.com").Page ("MLSListings.com").WebList("regions").Select "Itemname" Any Help? Thanks, Uma

2000


Please. Does someone know how to inicialize tapes in ATL? I need have 100 tapes to init inside the ATL, how is the process to complete this request?

1771


what are nanoemulsions and how are they prepared? i want a brief outline about nanoemulsions.. is anyone of you is having any literature, can you share that? also any an idea where i can get the information?

1766


can you provide me uniken pvt ltd. technical interview question and answer?

2848


What are your short and long term goals?

1902


How to score well in examination of MCA(engg) december 2012? please reply soon........

1607


how will u test the idoc

1750