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

In int main(int argc, char *argv[]) what is argv[0] a) The first argument passed into the program b) The program name c) You can't define main like that

1096


Evaluate as true or false: !(1 &&0 || !1) a) True b) False c) Invalid statement

1186


Define the operators that can be used with a pointer.

1060


In which header file does one find isalpha() a) conio.h b) stdio.h c) ctype.h

1211


What is the use of function pointer?

1027


How do I run c++?

1070


What is virtual destructor ans explain its use?

1130


Do class declarations end with a semicolon? Do class method definitions?

1150


What programming language should I learn first?

1101


Reads in the size of a square from the screen; 2. Prints a hollow square of that size out of “-“, “|” and blanks on screen; 3. Prints the same hollow square onto a text file. Your program should work for squares of all side sizes between 1 and 20. --- │ │ │ │ │ │ ---

2104


what is multi-threading in C++?

1057


Explain the concept of dynamic allocation of memory?

1100


Which is not a valid keyword a) public b) protected c) guarded

1263


Explain selection sorting. Also write an example.

1048


which of the following is not an secondary constant a) array b) real c) union

1804