Question: Let A and B be sets such that each has n positive integers in a non - decreasing order. We want to compute the set

Let A and B be sets such that each has n positive integers in a non-decreasing order. We want to compute the set C such that a in C if and only if a appears either (i) in both A and B, or (ii) more than once in A or B. For example, if A ={1,3,3,5,7} and B ={2,4,5,6,8}, then C ={3,5}. Give an O(n) time algorithm for the problem.

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!