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

Why hashtable is faster than arraylist?

993


What is difference between an Array and ArrayList?

1069


Explain implementation of deletion from a binary tree.

1020


What is storage structure in data structure?

965


What do you mean by articulation point?

1064


What are the major data structures used in the hierarchical data model?

1077


What is time complexity of binary search?

954


Can we add or delete an element after assigning an array?

1100


Which is the parent class of sortedset class?

1057


What is a directed graph?

1005


How to excel in data structures and algorithms?

1001


Write a program to reverse a link list.

988


Can you please explain the difference between array_name and &array_name?

1035


How to get a list of tables, views and columns in firebird database?

934


What are the 3 types of measurement?

1090