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's difference between stack and queue?
What are the advantage of linked list over array?
Tell me can the size of operator be used to tell the size of an array passed to a function?
Why do we need searching algorithms?
What is the structure of an array?
State the difference between arrays and linked lists?
Which interfaces are implemented by printerstatereasons?
What is structured data with example?
Is hashmap faster than arraylist?
For addition and deletion. Which one is most preferred: array list or linked list?
Can we extend an array after initialization?
Can hashmap have same key?
What do you mean by separate chaining?
Is hashset synchronized?
How do you find the index of an element in an arraylist?