Hi,
I have two lists, QList<int>list1;and QList<int>list2; List1 have 20 elements and list2 have 10 elements. I want to compare these two list and also want to store the matched elements in third list.
Thanks,
Monali.
Hi,
I have two lists, QList<int>list1;and QList<int>list2; List1 have 20 elements and list2 have 10 elements. I want to compare these two list and also want to store the matched elements in third list.
Thanks,
Monali.
You can get idea how to do that from this sample program
http://www.experts-exchange.com/Prog..._22974817.html
Complexity of algorithm is O(M * N), however, it can be reduced to O(M + N) in case lists are sorted.
In case you are looking for a way to do this with a Qt call: forget it.
I suggest you just u8se two for() lists, especially as the lists are so small...
The lines above are the best I have to offer.If anyone of you is of more advanced knowledge, I ask for your patience and understanding! - unknown arab poet
http://www.tamoggemon.com - Symbian blog - Windows Phone blog
My other blogs:
webOS blog iPhone blog BlackBerry blog Samsung bada blog Android blog
Well, you either compare every element in one to every element in the other, with two nested loops, or you use qSort to sort the lists and step through them in sync with each other.
Either way requires some actual programming skill, I'm afraid -- no cookbook.