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

What is the sequence of destruction of local objects?

976


What is a hash function c++?

1069


What are single and multiple inheritances in c++?

1095


What is the difference between ++ count and count ++?

1136


What are the types of pointer?

1093


What is the iunknown interface?

1123


Given the following seqment of code containing a group of nested if instructions: y = 9; if ((x==3) || (x == 5)) y++; else if (x == 2) y *= 2; else if (x == ) y-= 7; else y = 8; if the value of x is 4 before the nested IFs are executed, what is the value of y after the nested IFs are executed?

2021


Describe exception handling concept with an example?

1048


How do you instruct your compiler to print the contents of the intermediate file showing the effects of the preprocessor?

1143


Write a program which uses functions like strcmp(), strcpy()? etc

1094


What happens when the extern "c" char func (char*,waste) executes?

1087


What do you mean by function overriding & function overloading in c++?

1178


How do you save a c++ program?

1034


What is the error in the code below and how should it be corrected?

757


What is a constant? Explain with an example.

1006