find merging point of 2 linked lists


suppose there are two single linked lists both of which intersect at some point and became a single linked list. The head or start pointers of both the lists are known, but the intersecting node is not known. Also, the number of nodes in each of the list before they intersect are unknown and both list may have it different. List1 may have n nodes before it reaches intersection point and list2 might have m nodes before it reaches intersection point where m and n may be m = n, m<n or m>n. Give an algorithm for finding the merging point.


      1  -> 2 ->
                      \
                        3 -> 4-> null
                       /
10 - > 5 -> 11 

No comments :

Post a Comment