shiv@ubuntu:~/ds/list$ cat altxchangenode.c /* * program to Xchange or swap all the adjecent nodes(not node data) in the single linked list */ #include<stdio.h> #include<stdlib.h> #define MAX 10 struct list { int d; struct list *next; }; /* * function to swap 2 adjecent nodes(linkes) in the list */ void xchangenodes(struct list **head, struct list **ne, struct list **tm) { struct list *temp, *x1, *x2; if(*tm == NULL){ return; } if((*tm)->next && (*tm)->next->next){ /*next node when more than 3 nodes present in the list */ temp=(*tm)->next->next; } else if((*tm)->next){ if(*head != NULL) { /* only two nodes present in the list */ (*ne)->next = (*tm)->next; ...
C and Linux with Examples!!!