Is kd-tree always balanced?

后端 未结 3 1240
感动是毒
感动是毒 2021-02-14 08:59

I have used kd-tree algoritham and make tree.

But i found that tree is not balanced so my question is if we used kd-tree algoritham then that tree is always balanced if

3条回答
  •  甜味超标
    2021-02-14 09:09

    This is a fairly broad topic and the questions themselves are kind of general. Hopefully this will give you some useful insights and material to work with:

    • Kd tree is not always balanced.
    • AVL and Red-Black will not work with K-D Trees, you will have either construct some balanced variant such as K-D-B-tree or use other balancing techniques.
    • K-d Tree are commonly used to store GeoSpatial data because they let you search over more then one key, contrary to 'traditional' tree which lets you do single dimensional search. GeoSpatial data certainly cannot be represented in single dimension.

    Note that there are also specialized databases working with GeoSpatial data so it might be worth checking if the overhead could be shifted to them instead of making your own solution: Although i don't have much experience with this, maybe it is worth checking the postgis.

    postgis

    Here are some useful links showing how to build balanced K-D tree variant and usage of K-D trees with Spatial data:

    balancing K-D-Tree

    K-D-B-tree

    spatial data k-d-trees

提交回复
热议问题