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 hashtable is faster than arraylist?
What is difference between an Array and ArrayList?
Explain implementation of deletion from a binary tree.
What is storage structure in data structure?
What do you mean by articulation point?
What are the major data structures used in the hierarchical data model?
What is time complexity of binary search?
Can we add or delete an element after assigning an array?
Which is the parent class of sortedset
What is a directed graph?
How to excel in data structures and algorithms?
Write a program to reverse a link list.
Can you please explain the difference between array_name and &array_name?
How to get a list of tables, views and columns in firebird database?
What are the 3 types of measurement?