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

State the difference between persistent and ephemeral data structure?

1611


What is the impact of signed numbers on the memory?

890


What is range search?

841


What is the method to find the complexity of an algorithm?

1051


What do you mean by sorting data?

834


What is a data structure? What are the types of data structures? Briefly explain them

914


Which sorting is best for large data?

871


Why do we use stacks?

866


What do you mean by structure property in a heap?

1024


Explain binary tree traversals?

869


How do we find duplicate elements in an array?

924


How do you sort a list in reverse order?

774


What are the advantages of array?

854


Can you sort a string?

757


Is hashtable throw concurrentmodificationexception?

708