Answer the question
In order to leave comments, you need to log in
What is the algorithm to find the nearest "special" number?
Suppose there is an indexed "huge" set of natural numbers and there is an array of "special" natural numbers (we can assume that the special ones are simple, or perfect, or the relative coordinates of the houses of All-All-All Friends and Relatives of the Rabbit relative to the hole of the Rabbit itself). It is necessary to find the closest "special_number" relative to arbitrary X. What are the options?
I see two:
-- build the set of differences of X and all "special_numbers" and take the smallest. But if there are about the same number of "special numbers" as there are numbers in the "huge set", then this is a long time, because the resulting set of differences is not indexed.
-- sort the "huge set" and by removing by one find the nearest "special" in one direction, and then in the other direction. Compare these two distances. But it will be long if there are few "special" numbers.
What other options are there?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question