×
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
1391    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.
Rabindranath Tagore
We come nearest to the great when we are great in humility.
Rabindranath Tagore
2050
60.43
Today So Far
Total View (Lakh)
softetechnologies
26/05/2018     44655
01/01/2018     36856
25/06/2018     36685
28/06/2017     34875
02/08/2017     33472
01/08/2017     27830
06/07/2017     27599
15/05/2017     27166
14/07/2017     22912
11/09/2018     21630
softetechnologies