Compare two linked list

How to compare two linked lists? Write a C program to compare two linked lists.

Comments

  1. int compare_linked_lists(struct node *q, struct node *r)
    {
    static int flag;
    if((q==NULL ) && (r==NULL))
    {
    flag=1;
    }
    else
    {
    if(q==NULL || r==NULL)
    {
    flag=0;
    }
    if(q->data!=r->data)
    {
    flag=0;
    }
    else
    {
    compare_linked_lists(q->link,r->link);
    }
    }
    return(flag);
    }

    ReplyDelete

Post a Comment

Popular posts from this blog