Re:The skyline problem
by michaelmior on Tuesday September 02, 2014 @08:28AM
(#8257128)
My first thought was to dump the rectangles into an interval tree. Also O(n log n), but less space efficient since it always requires O(n) space regardless of the structure of the problem.
[ Parent
| on HN ]
Re:The skyline problem
by brianpgordon on Tuesday September 02, 2014 @09:12PM
(#8261070)
Are you sure that it's n log n? I think that the pyramid shaped configuration defeats this strategy by forcing the interval tree to report something on the order of n intervals with every query. So there are n queries on the interval tree, and each query takes log(n) + n time.
Also, something interesting to note that I was thinking about yesterday is that you don't actually need to use an interval tree for this. You can use a range tree instead, which is simpler (to my mind). You only need an interval tree to do a certain kind of query which we never need to do:
Re:The skyline problem
by michaelmior on Tuesday September 02, 2014 @09:16PM
(#8261085)
I'm not sure what you mean by the pyramid-shaped configuration. In any case, n queries taking log(n) + n time each is O(n log n). I think you're right that a range tree should work fine.
Re:The skyline problem
by brianpgordon on Tuesday September 02, 2014 @10:26PM
(#8261246)
I mean this thing from the article:
https://briangordon.github.io/images/worstcase.svg
> n queries taking log(n) + n time each is O(n log n)
No, it's O(n^2).
Re:The skyline problem
by michaelmior on Tuesday September 02, 2014 @10:29PM
(#8261256)
Wow, clearly commenting too late. Of course you're right :)