問題詳情

14. Consider the following three problems. Assume that the only operations allowed on the data are●comparing the values of two floating-point numbers and identifying the larger value;
●comparing the distance between two array entries (the absolute value of the difference between the two array entries) with the distance between two other array entries;
●swapping two entries in the array.
Further assume that each allowed operation has unit cost. What are the worst-case optimal asymptotic running times for algorithms that solve these problems?


【題組】(40) Nearest Neighbors: Given an unsorted array of n floating-point numbers as input, return two or the numbers that are closest in value to each other.
(A)O(n log n)
(B)O(log n)
(C)O(n2)
(D)O(n3)
(E)O(n)

參考答案

答案:[無官方正解]
難度:計算中-1
書單:沒有書單,新增