Page 55 - DCAP605_ADVANCED_DATA_STRUCTURE_AND_ALGORITHMS
P. 55

Advanced Data Structure and Algorithms




                    Notes                     do

                                                    {
                                                    printf(“%d\t”,temp->data);
                                                    temp=temp->link;
                                                    } while (temp!= p);
                                            }
                                        else
                                              printf(“The list is empty\n”);
                                         }
                                        struct node *merge(struct node *p, struct node *q)
                                             {
                                               struct node *temp=NULL;
                                               struct node *r=NULL;
                                               r = p;
                                               temp = p;
                                               while(temp->link != p)
                                                    temp = temp->link;
                                               temp->link = q;
                                               temp = q;
                                               while( temp->link != q)
                                                   temp = temp->link;
                                               temp->link = r;
                                              return(r);
                                        }
                                        void main()
                                        {
                                              int n;
                                              int x;
                                              struct node *start1=NULL ;
                                              struct node *start2=NULL;
                                              struct node *start3=NULL;
                                             /* this will create the first circular list nodes*/
                                              printf(“Enter the number of nodes in the first list \n”);
                                              scanf(“%d”,&n);
                                              while ( n-- > 0 )
                                              {
                                           printf( “Enter the data value to be placed in a node\n”);
                                                   scanf(“%d”,&x);
                                                   start1 = insert ( start1, x );
                                              }
                                              printf(“The first list is\n”);




          50                               LOVELY PROFESSIONAL UNIVERSITY
   50   51   52   53   54   55   56   57   58   59   60