INTERSECT(p1,p2)
1 answer <----()
2 while p1 not equal Nil and p2 not eqaul Nil
3 do if docId(p1) = docId(p2)
4 then ADD (answer, docId(p1))
5 p1 <--- next(p1)
6 p2 <---- next(p2)
7 else if docId(p1) < docId(p2)
8 then p1<--- next(p1)
9 else p2<--- next(p2)
10 return answer

It seems as if you're just asking us to do your homework for you, without even taking the time to explain to us what the assignment is. I get that you want help converting an algorithm to C++, but you're not doing a clear job expressing what the algorithm is, and what it's designed to do. What are p1 and p2? What do they represent? What does answer<---() even mean??

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.