create an singly linked lists and reverse the lists by
interchanging the links and not the data?
Answer Posted / kushal bagaria
struct node
{
int data;
struct node *list;
};
reverse(&p) /* p is the pointer to the 1st node of ll*/
function reverse:-
reverse(struct node **q)
{
struct node *r,*t,*prev;
r=*q;
prev= NULL;
while(r!=NULL)
{
t=prev;
prev=r;
r=r->link;
prev->link=t;
}
*q=prev; /* last node bcoms d root of ll */
}
| Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
What is a directed graph?
What is the complexity of sorting algorithm?
What are the properties of binary heap?
What is sorting in math?
What’s the difference between enumeration and iterator interfaces?
What are the advantages of linked list over array (static data structure)?
Define an algorithm. What are the types of algorithms?
How many types of lists are there?
What is time and space complexity of bubble sort?
What are the advantages of array?
How does bogo sort work?
List some applications of tree-data structure?
Explain the Queue
Can we store null in arraylist?
What is selection in an algorithm?