Use two pointers to traverse both the linked-lists.
while(List1 && List2)
{
if(List1->data == List2->data ), then add it to the
Intersect_List.
if(List1->data < List2->data ) then move List1 pointer i.e.
List1=List1->next;
else move List2 pointer i.e. List2=List2->next;
}
return the intersectList.
--
Navin Kumar Gupta
Final Year,B.Tech(Hons.)
Computer Science & Engg.
National Institute of Technology,Jamshedpur
Mobile - (+91)8285303045
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/algogeeks/-/hk3K2Z0WQ0kJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.