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 / patrick

You cannot must have a pointer to a pointer if you want to
modify the pointer.

void reverse(node** head)
{
node* cur = *head;
*head = null;

while (cur)
{
node* next = cur->next;
cur->next = *head;
*head = cur;
cur = next;
}
}

Besides the head pointer, you will need two local pointers.

Is This Answer Correct ?    4 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is there a sort function in c++?

1004


Is c++ a pure oop language?

1085


What is a map in c++?

1214


What are the effects after calling the delete this operator ?

1059


Which is better c++ or java?

985


What is abstract class in c++?

1055


what is the use of void main() in C++ language?

1124


find the two largest values among the 6 numbers using control structures : do-while,for,if else,nestedif- else ,while. one or two of them.

2547


What are the 3 levels of programming languages?

1048


What is a Default constructor?

1599


Where is atoi defined?

1144


List the types of polymorphism in c++?

1106


What is the use of "new" operator?

1137


Can turbo c++ run c program?

1099


What is c++ namespace?

1214