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


Please Help Members By Posting Answers For Below Questions

State the rules to be followed during infix to prefix conversions?

808


What do you mean by secondary clustering?

664


Explain multiply linked list in short.

683


Why would you use a linked list?

659


What is example of data?

703






How is bubble sort done?

621


Define probing?

882


Explain the uses of binary tree.

691


How to reverse singly link list?

683


What is the use of tree data structure?

633


What are the applications of priority queues?

690


What are the properties of binary tree?

676


Explain how is linked list implemented?

684


Which method will arrange the element of an array in alphabetical order?

1758


Explain merge sort algorithms.

756