Hi my friends, how do you do?

I hope everything is alright.. :)


Please may I have a few mins. from your time? It'll be much more appreciated :)

I have this question
(Write a member function to check whether two singly linked lists have the same contents.)


anyone can help me solving this question, plz?


thanks in advance... Be sure, I'll be thankful if I get a few mins. from your time to solve this question :)..

About the rules Yes, I know them

But this is not from my personality to lie at ppl :\

I'll tell the truth that really I don't know anything about the linked lists :\

if I give it a try

I would say (this code below)

void checkEquality()
{
for( int i = 0; i < 
}

then I get stuck there..

Please, Absolutely this is my 1st time asking for something without doing a big work :\

I'm really getting stuck in that step

also, it is not a homework

I'm studying for my midterm and trying to solve the problem sets in the book

Thanks in advance.. waiting your help :)

Thanks a lot Narue you saved me in some questions I was getting stuck with them xDD

but for my question I didn't figure how to implement the code for TWO singly linked lists :'[

It looks confusing because for one for loop I can take one singly linked list,, and for two!! How I can do it???

Please, it is a function not a program!!

or at least tell me and I'll implement it :)

>but for my question I didn't figure how to implement the code for TWO singly linked lists :'[
Dude, it's just like using two arrays. Please don't tell me you're as dense as that statement suggests.

so you meant, I'll use the code as they're two arrays!!

I meant, you can have more than one linked list:

node *it1 = head1;
node *it2 = head2;

while ( it1 != 0 && it2 != 0 ) {
  if ( it1->data != it2->data )
    break;
}

if ( it1 == 0 && it2 == 0 )
  cout<<"Equal";
Comments
You saved me :D

Do you know about templates? You could create a Linked List template class to make things easier to understand. Though, on second thought, creating a linked list template class can be a hassle, and giving you one wouldn't teach you anything about linked lists.

Narue,, thank you so much.. it did came in the midterm and I solve it in the way you said xDD

thank you so much,, (Added Rep for you) :)

++++++++

CoolGamer

I don't think it needs the Template because the question want only the member function so no need for the other details ;)


thanks again guys :)

This question has already been answered. Start a new discussion instead.