#include #include #include #define MAX 1000 typedef struct _node { int key; struct _node *next; } node; node *buildList ( int n ) { node *p, *head; int i; if (n <= 0) return NULL; head = p = (node *)malloc(sizeof(node)); p -> key = rand() % MAX; for (i=1; i next = (node *)malloc(sizeof(node)); p -> next -> key = rand() % MAX; p = p -> next; } p -> next = NULL; return head; } void printList ( node *p ) { int cnt = 0, nelp = 7; while (p != NULL) { printf("%4d", p -> key); p = p -> next; ++cnt; if (++nelp == 18) { printf("\n"); nelp = 0; } } if (nelp != 0) printf("\n"); printf("Total count = %d\n", cnt); } node *splitList ( node *p ) { } node *joinList ( node *p, node *q ) { } int main () { node *p, *q, *t; unsigned int n; srand((unsigned int)time(NULL)); printf("Enter the size of the list: "); scanf("%u", &n); printf("%d\n", n); p = buildList(n); printf("The list before splitting : "); printList(p); q = splitList(p); printf("Sublist with smaller keys : "); printList(p); printf("Sublist with larger keys : "); printList(q); t = joinList(p,q); printf("The list after joining : "); printList(t); }