Insertion in sorted Doubly linked list by R4R Team

Following function are used to insert the data in sorted Doubly linked list:

void insertion(int n)
{
struct node *ptr=first,*cpt,*newp;
while(ptr->data< n)
{
cpt=ptr;
ptr=ptr->next;
}
newp=(struct node*)malloc(sizeof(struct node));
newp->data=n;
cpt->next=newp;
newp->pre=cpt;
newp->next=ptr;
ptr->pre=newp;
}




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!