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 method is used to place a value onto the top of a stack?

1018


List the differences between comparable and comparator interface?

922


What is the purpose of thread?

948


Write a program using mergesort technique.

1000


What is unhashable type list?

839


Are hash tables ordered?

891


What are the applications of graph data structure?

903


List out the basic operations that can be performed on a stack?

873


how to display Singly Linked List from First to Last?

887


Is learning data structures necessary?

874


what are the applications of Linked Lists?

1009


What is difference between array and string?

984


Which collection type is used to maintain uniqueness of data structure?

1472


What is bubble sort with example?

917


How many types of linked list exist?

960