• Courses
  • Tutorials
  • DSA
  • Data Science
  • Web Tech
June 03, 2022 |1.5K Views

K-Dimensional Tree [Find Minimum]

Description
Discussion

In KD tree, points are divided dimension by dimension. For example, root divides keys by dimension 0, level next to root divides by dimension 1, next level by dimension 2 if k is more then 2 (else by dimension 0), and so on.

To find minimum we traverse nodes starting from root. If dimension of current level is same as given dimension, then required minimum lies on left side if there is left child. This is same as Binary Search Tree Minimum.

Above is simple, what to do when current level’s dimension is different. When dimension of current level is different, minimum may be either in left subtree or right subtree or current node may also be minimum. So we take minimum of three and return. This is different from Binary Search tree.

K-Dimensional Tree [Find Minimum]: https://www.geeksforgeeks.org/find-minimum-in-k-dimensional-tree/