Question: Let A = {a1, a2, , an} and B = {b1, b2, , bm} be two sets of integers. The problem is to find the

Let A = {a1, a2, , an} and B = {b1, b2, , bm} be two sets of integers. The problem is to find the intersection of sets A and B, i.e., the set C of all the numbers that are in both A and B.

[a] Design a brute-force algorithm for solving this problem.

[b] Perform an analysis of your brute-force algorithm, i.e., compute the number of times its basic operation is executed and then determine the efficiency class of the algorithm.

[c] Design a transform-and-conquer algorithm for solving this problem. Specifically, design a presorting-based algorithm. The total running time for your algorithm should be no more than O(n log n).

[d] Perform an analysis of your transform-and-conquer (presorting) 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 Databases Questions!