×
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
1903    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.
Nelson Mandela
Education is the most powerful weapon which you can use to change the world.
Nelson Mandela
1469
79.49
Today So Far
Total View (Lakh)
softetechnologies
26/05/2018     53834
25/06/2018     44915
01/01/2018     43494
28/06/2017     41068
02/08/2017     40046
01/08/2017     34089
06/07/2017     33920
15/05/2017     33173
11/09/2018     29919
14/07/2017     29627
softetechnologies