Suppose we have an association
assoc = <| 1 -> 1, 3 -> 2, 5 -> 3, 7 -> 4, 20 -> 5|>;
Instead of checking if a specific key exists in this association, can I use
Association to "efficiently" find the maximum key (or minimum key) which is less(larger) than or equal to a specific value? I.e., I want to find the upper or lower bound of the given
Association with in a time less than
N is the length of the
Association. Please note that many kinds of balanced tree data structures allow such functionality.
In this specific example,
lower(assoc, 10) == 7 and
lower(assoc, 6) == 5 are the desired results. If it cannot be applicable for this situation, what is the best way(or data structure and so on) for this purpose in MMA?