Posts

Showing posts with the label Program to concatenate one linked list at end of another

Program to concatenate one linked list at end of another

#include #include #include struct node { int data ; struct node *link ; } ; void append ( struct node **, int ) ; void concat ( struct node **, struct node ** ) ; void display ( struct node * ) ; int count ( struct node * ) ; struct node * erase ( struct node * ) ; void main( ) { struct node *first, *second ; first = second = NULL ; /* empty linked lists */ append ( &first, 1 ) ; append ( &first, 2 ) ; append ( &first, 3 ) ; append ( &first, 4 ) ; clrscr( ) ; printf ( "\nFirst List : " ) ; display ( first ) ; printf ( "\nNo. of elements in the first Linked List = %d", count ( first ) ) ; append ( &second, 5 ) ; append ( &second, 6 ) ; append ( &second, 7 ) ; append ( &second, 8 ) ; printf ( "\n\nSecond List : " ) ; display ( second ) ; printf ( "\nNo. of elements in the second Linked List = %d", count ( second ) ) ; /* the result obtained after concatenation is in the first list */ conca...