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
What the principle of quick sort and its complexity?
What type of variable is age?
Why quicksort is called quick?
Define 2-3 tree?
Does the minimal spanning tree of a graph give the shortest distance between any 2 specified nodes?
What is array and its types in data structure?
What is linear-logarithm chasm?
Explain about set and their types in a collection?
What is the difference between an array and vector?
What is the difference between null and void?
Is treemap thread safe?
Can we use ordered set for performing binary search?
What is a spanning tree in data structure?
What is link list in data structure?
What are the issues that hamper the efficiency in sorting a file?