Program to sort a linked list by swapping data
#include #include #include /* structure containing a data part and link part */ struct node { int data ; struct node *link ; } *newnode, *start, *visit ; void getdata( ) ; void append ( struct node **, int ) ; void displaylist( ) ; int count ( struct node * ) ; void selection_sort ( int ) ; void bubble_sort ( int ) ; void main( ) { int n ; getdata( ) ; clrscr( ) ; printf ( "Linked List Before Sorting: " ) ; displaylist( ) ; n = count ( start ) ; selection_sort ( n ) ; printf ( "\nLinked List After Selection Sorting: " ) ; displaylist( ) ; getch( ) ; getdata( ) ; clrscr( ) ; printf ( "Linked List Before Sorting: " ) ; displaylist( ) ; n = count ( start ) ; bubble_sort ( n ) ; printf ( "\nLinked List After Bubble Sorting: " ) ; displaylist( ) ; getch( ) ; } void getdata( ) { int val, n ; char ch ; struct node *new ; clrscr( ) ; new = NULL ; do { printf ( "\nEnter a value: " ) ; scanf ( "%d", &...