Question: Suppose an algorithm A_1 divides (in linear time) the input into six equal parts P_1, P_2, P_3, P_4, P_5, P_6. It then makes the following

 Suppose an algorithm A_1 divides (in linear time) the input into

Suppose an algorithm A_1 divides (in linear time) the input into six equal parts P_1, P_2, P_3, P_4, P_5, P_6. It then makes the following 10 combinations of these parts: each odd part is combined with each even part: P_1 with P_2, P_4, P_6 and so on, and in addition P_1 is combined with P_3. The algorithm is then run recursively on each of those 10 combinations. The results of the recursive runs are combined in quadratic time to produce the final output. Another algorithm, A_2, divides the input into nine equal parts and runs on a (some number) of them recursively. It then combines the results of the recursive runs in quadratic time to produce the final output. Write the expression for the running time of each of those two algorithms. Suppose we are given two n-element sorted sequences A and B that should not be viewed as sets (that is, A and B may contain duplicate entries). (a) Describe an O(n)-time algorithm^2 for computing a sequence representing the set A intersection B. (b) If the sequences A and B are instead unsorted, what is asymptotic time complexity of the most efficient algorithm that you can construct that computes A intersection B? Describe this 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!