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
how to avoid a class from getting inherited but respective class should be able to instantiate ?
Just a one miniute topics in English?
Why does the 'divisibility by 3' rule work?
is there any better model than jcb 3dx
explain bug tracking system in detail.
Show the forces acting on a ladder
compair and contrast procedrual and object oriented programming language
What is the significance of superconductors?
Write a c pgm to print the letter as per given condition i.e.. if u give 4 out put should b 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
Briefly describe your ideal job?
c# code, vb.net code language parity refers to what?
consiteunts of indian railways
what are the various height of GSM mount and its base width ashim.port@gmail.com
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?
sir , i am prparing for IOCL engineergin post please send me the old placement papers