traverse(at, a)
if( is_member(at, b) )
result.insert(at);
Now, your `is_member()' function is traversing all the list to find the element.
Your algorithm ends being O(n*m)
If the lists were sorted then you may stop as soon as you find a bigger element.
Also, there is no need to start at the beginning of the list because you know that till some point all those element are lesser than the one you're searching