Insertion in sorted linked list by R4R Team

Example-
Linked list is : 2->4->5->8->9
Insertion of 6
Linked List become : 2->4->5->6->8->9

Function:

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->next=ptr;
}




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!