954,499 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

comparing and doing something between two Linked List

please help me with this problem: i have to linked list, i need to compare them, and do something with regards to there result..

meekblood25
Newbie Poster
1 post since Dec 2007
Reputation Points: 10
Solved Threads: 0
 

And? What's the problem? Presumably you're traversing both arrays to compare them and stopping when they're obviously different or at the end:

while ( a != NULL && b != NULL
  && a->data == b->data )
{
  a = a->next;
  b = b->next;
}

if ( a == NULL && b == NULL )
  /* They're equal */
else if ( a == NULL )
  /* a is smaller */
else if ( b == NULL )
  /* b is smaller */
else if ( a->data < b->data )
  /* a is smaller */
else if ( b->data < a->data )
  /* b is smaller */
Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You