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

Do you know the problem with overriding functions?

1034


How can I disable the "echo" feature?

1086


Is rust better than c++?

1054


What is virtual base class uses?

1237


What is the object serialization?

1090


Difference between overloaded functions and overridden functions

1000


What is namespace & why it is used in c++?

1037


Is nan a c++?

1090


an operation between an integer and real always yeilds a) integer result b) real result c) float result

1105


What is the best ide for c++?

1038


Why cstdlib is used in c++?

993


Tell me can a pure virtual function have an implementation?

965


Where the memory to the static variables is allocated?

997


What is c++ code?

1071


What are the manipulators in c++?

978