Question: Write an algorithm for a function with two n elements, consisting of integers and taking an ordered sequence from small to large as input and

Write an algorithm for a function with two n elements, consisting of integers and taking an ordered sequence from small to large as input and returning another sequence consisting of numbers present in both arrays. Even in the worst case of your algorithm, the time complexity must be o(n), that is, linear.

So

The algorithm is the findsame_things (A{0..n-1], B [0..n-1]) // Input: a sequence of ordered integers with two n elements // Output: the third sequence of integers present in both sequences

Can you write the pseudo code?

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!