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...

How many pointers are required to reverse a link list?

Answer Posted / prits

Using 3 pointers:
curr, next, result pointers, curr points to current node,
next obviously points to the next node, result points to
the new reversed linked list

void reverse_single_linked_list(struct node** headRef)
{
struct node* result = NULL;
struct node* current = *headRef;
struct node* next;
while (current != NULL)
{
next = current->next; // tricky: note the next node
current->next = result; // move the node onto the result
result = current;
current = next;
}
*headRef = result;
}

Is This Answer Correct ?    14 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are friend classes? What are advantages of using friend classes?

1105


What is extern c++?

1005


Incase of a function declaration, what is extern means?

968


Why do we use templates?

1044


What is == in programming?

1011


Is there structure in c++?

1024


What is class invariant in c++?

1227


When should we use multiple inheritance?

1041


Write a corrected statement in c++ so that the statement will work properly. if (4 < x < 11) y=2*x;

2013


Does there exist any other function which can be used to convert an integer or a float to a string?

1076


describe private access specifiers?

1233


What is virtual destructor ans explain its use?

1128


What is the full form nasa?

1093


What are the defining traits of an object-oriented language?

1201


What is meant by a delegate?

1089