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
Why we use linked list?
Can we declare array size as a negative number?
Explain merge sort algorithms.
Define a set?
Can list contain null values?
What do you mean by Runtime Error
What are the disadvantages of circular list?
What do you mean by back edge?
What is the most used data structure?
Define parent node?
What is a hash in programming?
What is worst case complexity algorithm?
What is the difference between a push and a pop?
How do you find the complexity of a selection sort?
When should structures be passed by values or by reference?