Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Linked List reverese program

Answer Posted / kaustubh

I'll give the algo here.You may write it in a programming
language of your choice.

Iterative Algo:

node *Reverse(node *head)
{
node *p,*q,*r;
p=head;q=r=NULL;
while(p!=NULL)
{
q=p;
p=p->next;
q->next=r;
r=q;
}
head=q;
return head;
}

Recursive algo:

From main call: Reverse(node *head,NULL)

reverse(node *p,node *q)
{
if(p->next!=NULL)
reverse(p->next,p)
else
{
p->next=q;
return
}
}

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is it necessary that each try block must be followed by a catch block?

971


How do you define a variable?

892


What is starvation?

1215


What languages are pass by reference?

989


What is the difference between this() and super() in java?

983


Why unicode is important?

892


how to create multithreaded program? Explain different ways of using thread? When a thread is created and started, what is its initial state? : Java thread

955


Can you extend main method in java?

1094


what is the purpose of the wait(), notify(), and notifyall() methods? : Java thread

928


Can a final variable be null?

952


What is the difference between notify and notifyall method?

1105


How many arguments can a method have java?

976


Explain the inheritance?

923


What is a treeset in java?

989


What occurs when an object is constructed?

937