Question: Let A = { x 1 , x 2 , . . . , xn } and B = { y 1 , y 2

Let A={ x1, x2,..., xn } and B ={ y1, y2,..., yn} be two lists, each with n unique integer elements. Consider the problem of finding their intersection i.e. elements they have in common.
a) Give (in details) a brute-force algorithm for solving this problem and determine its efficiency. May either describe or give pseudo code.
b) What if the two list are sorted? Suggest an algorithm with most improved time complexity to find the intersection of the two list. Give the efficiency of your the algorithm.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!