Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Compare two linked lists A and B
- Return 1 if they are identical and 0 if they are not.
- Node is defined as
- struct Node
- {
- int data;
- struct Node *next;
- }
- */
- int CompareLists(Node *headA, Node* headB)
- { if((headA==NULL) && (headB==NULL)) return 1;
- while(1){
- if((headA->data)!=(headB->data)) return 0;
- else if(((headA!=NULL) && (headB==NULL))||((headA==NULL) && (headB!=NULL))) return 0;
- else if((headA==NULL) && (headB==NULL)) break;
- else {
- headA=headA->next;
- headB=headB->next;
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement