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 list and types of list?
What is the difference between a push and a pop?
What is a data structure? What are the types of data structures?
Can you store different types in an array?
Have you ever used HashTable and Directory?
Which sorting is best and why?
How do you make a bubble chart with 3 variables?
What is the difference between array and stack?
Explain the most efficient method to reverse a linked list?
Explain the terms base case, recursive case, binding time, run-time stack and tail recursion.
How do I sort a hashmap key?
What is the best time complexity of bubble sort?
What is the most used data structure?
How to excel in data structures and algorithms?
What is array and string?