You are given two sets of integers, sizes M and N with M < N. Perform inner equal join on these two sets (i.e., find intersection of the two lists). How to perform it if both the lists are in files and the available memory is of size K < M < N
Share
Using an in-place sorting algorithm to sort both the lists first.
Once both M an N are sorted, then calculating the intersection is like a race. Place two markers
aandbat the beginning of each list. Do these steps until any marker reaches the end of the list. In pseudocode:Given a decent in-place sorting algorithm, the complexity of this will be
O(nlogn).