×
FREE ASSISTANCE FOR THE INQUISITIVE PEOPLE
Tutorial Topics
X
softetechnologies
Display The Link List Elements In C Sort the List Elements - Link List in C
Reverse The Link List Elements - Link List in C - Link list - C Language
1082    Arnab De    07/09/2019

We can reverse the linklist elements by adjusting the node references only. That is, change the fist node into last.

softetechnologies
node *rev(node *l)
{
	node *temp1,*temp2,*temp3;
	int c=1;
	temp1=l;
	temp2=l;
	do
	{
		temp3=temp2->next;
		if(c==1)
		{
			temp2->next=NULL;
			temp2=temp3;
			temp3=temp3->next;
		}
		else
		{
			temp2->next=temp1;
			temp1=temp2;
			temp2=temp3;
			temp3=temp3->next;
		}
		c++;
	}while(temp3!=NULL);
	temp2->next=temp1;
	return temp2;
}
softetechnologies
Display The Link List Elements In C Sort the List Elements - Link List in C
softetechnologies
Author Details
Arnab De
I have over 16 years of experience working as an IT professional, ranging from teaching at my own institute to being a computer faculty at different leading institute across Kolkata. I also work as a web developer and designer, having worked for renowned companies and brand. Through tutorialathome, I wish to share my years of knowledge with the readers.
Enter New Comment
Comment History
No Comment Found Yet.
Sri Sri Ramakrishna Paramahamsa
One cannot be spiritual as long as one has shame, hatred, or fear.
Sri Sri Ramakrishna Paramahamsa
604
51.37
Today So Far
Total View (Lakh)
softetechnologies
26/05/2018     41662
01/01/2018     35880
28/06/2017     33905
25/06/2018     33093
02/08/2017     32257
06/07/2017     26687
01/08/2017     26673
15/05/2017     26298
14/07/2017     21663
21/04/2018     20589
softetechnologies