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
State the difference between persistent and ephemeral data structure?
What is the impact of signed numbers on the memory?
What is range search?
What is the method to find the complexity of an algorithm?
What do you mean by sorting data?
What is a data structure? What are the types of data structures? Briefly explain them
Which sorting is best for large data?
Why do we use stacks?
What do you mean by structure property in a heap?
Explain binary tree traversals?
How do we find duplicate elements in an array?
How do you sort a list in reverse order?
What are the advantages of array?
Can you sort a string?
Is hashtable throw concurrentmodificationexception?