Range Searching

So far, we have looks for one specific item.

New operation : look for all items that fall within a given range.

  • Input: A range, i.e. an interval
    • May be open or closed at the ends
  • Want: Report all KVPs in the dictionary whose key satisfies

  • Let be the output-size, i.e. the number of items in the range

Note

Sometimes and sometimes ; we therefore keep it as a separate parameter when analyzing the run-time.

Range searches in existing dictionary realizations

Unsorted array: Range search requires time: We have to check for each item explicitly whether it is in the range.

Sorted array: Range search on A can be done in :

BST: Range searches can similarly be done in time time. Will see this later in detail? In BST range search, there are always distinct nodes?

(Orthogonal) d-dimensional range search: Given a query rectangle , find all points that lie within .

The time for range searches depends on how the points are stored.

  • We can store the points in a 1-dimensional dictionary Problem: range search on one aspect is not straightforward??
  • We can use one dictionary for each aspect Problem inefficient, waste of space

Better idea: Design new data structures specifically for points.

Definition of aspect: each item has d aspects (coordinates): . Aspect values () are numbers. Each item corresponds to a point in d-dimensional space. Concentrate on .

Range search Data Structures summary

Questions

In BST range search, there are always distinct nodes.

  • False, why?

The best-case runtime of a 1-dimensional range search on a balanced binary search tree with nodes is:

  • ???? What about the worst-case: ? I don’t remember why?