Course Solutions Uncategorized (Solved) : Consider Following Problem Input Array N Distinct Numbers Array B N Numbers Different Orde Q32730653 . . . .

(Solved) : Consider Following Problem Input Array N Distinct Numbers Array B N Numbers Different Orde Q32730653 . . . .

 

Consider the following problem:

• Input: an array A with n distinct numbers, and an array B withthe same n numbers in a different order.

• Output: the goal is find the number whose position in A ismost similar to its position in B. Formally, say that a pair (i, j)is related if A[i] = B[j]; we want to find the related pair thatminimizes |j − i|. If there multiple pairs that minimize |j − i|,you only have to return one of them.

Write pseudocode for an algorithm that solves this problem inO(n) expected time.

Expert Answer


An answer will be send

OR

PayPal Gateway not configured

OR

PayPal Gateway not configured

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post