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 is difference between capacity and size of arraylist?
How do you do a selection sort?
Is binary tree balanced?
Why sorting is used?
Why is hashmap faster than treemap?
How do you find the time complexity of a bubble sort?
What is linked list ?
Why is null not allowed in concurrenthashmap?
What happens if we put a key object in a hashmap which exists?
Write a code for dynamic allocation of array.
What is stable sorting?
Where is binary tree used?
Define a full binary tree ?
How many types of data structures are there?
What is a height of a tree?