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

create an singly linked lists and reverse the lists by
interchanging the links and not the data?

Answer Posted / nash

If the Linked list is small enough i'd use a recursive function.

reverse(head, head, NULL);

void reverse(Node* headNode, Node* currNode, Node* prevNode)
{
if(headNode != NULL && currNode != NULL)
{
reverse(currNode.next, currNode);
}
else
{
headNode = currNode; // Reached the end of the list.
}

currNode.next = prevNode;
}

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What the principle of quick sort and its complexity?

922


What type of variable is age?

806


Why quicksort is called quick?

858


Define 2-3 tree?

918


Does the minimal spanning tree of a graph give the shortest distance between any 2 specified nodes?

903


What is array and its types in data structure?

887


What is linear-logarithm chasm?

970


Explain about set and their types in a collection?

792


What is the difference between an array and vector?

961


What is the difference between null and void?

897


Is treemap thread safe?

847


Can we use ordered set for performing binary search?

856


What is a spanning tree in data structure?

912


What is link list in data structure?

842


What are the issues that hamper the efficiency in sorting a file?

935