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 method is used to place a value onto the top of a stack?
List the differences between comparable and comparator interface?
What is the purpose of thread?
Write a program using mergesort technique.
What is unhashable type list?
Are hash tables ordered?
What are the applications of graph data structure?
List out the basic operations that can be performed on a stack?
how to display Singly Linked List from First to Last?
Is learning data structures necessary?
what are the applications of Linked Lists?
What is difference between array and string?
Which collection type is used to maintain uniqueness of data structure?
What is bubble sort with example?
How many types of linked list exist?