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
Is hashmap keyset ordered?
Explain the term tail recursion?
For the following COBOL code, draw the Binary tree? 01 STUDENT_REC. 02 NAME. 03 FIRST_NAME PIC X(10). 03 LAST_NAME PIC X(10). 02 YEAR_OF_STUDY. 03 FIRST_SEM PIC XX. 03 SECOND_SEM PIC XX.
Define general trees?
Why sorting is done?
What is data structure and data type?
Explain recursive function & what is the data structures used to perform recursion?
How does dynamic memory allocation help in managing data?
Is arraylist synchronized?
Which is better hashmap or treemap?
Can a null element added to a treeset or hashset?
What is binary tree used for?
Write an algorithm to find middle element in the linked list.
Define b-tree of order m?
What are the applications of graph data structure?