Course Solutions Uncategorized (Solved) : 2 20 Pts Consider Following Problem Input Array 1 N Distinct Integers Integer X Output Ran Q30331055 . . . .

(Solved) : 2 20 Pts Consider Following Problem Input Array 1 N Distinct Integers Integer X Output Ran Q30331055 . . . .

 

2. (20 pts) Consider the following problem. Input: array A[1 ton] of distinct integers, and integer x Output: the rank of theinteger closest to x in AHere the rank means the minimum rank,i.e., the rank of the smallest in A is 1, that of the 2ndsmallestis 2, etc. Consequently if the element closest to x is the kthsmallest of A, the output is k. For example,

if A[1 to 4]={ 8, 1, 5, 20} and x=4, the output is 2 because theclosest to 4 is 5, having rank 2. If x=3, the output can be either1 or 2.

Design a linear time

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