M-tree
In computer science, M-trees are tree data structures that are similar to R-trees and B-trees. It is constructed using a metric and relies on the triangle inequality for efficient range and k-nearest neighbor (k-NN) queries. While M-trees can perform well in many conditions, the tree can also have large overlap and there is no clear strategy on how to best avoid overlap. In addition, it can only be used for distance functions that satisfy the triangle inequality, while many advanced dissimilarity functions used in information retrieval do not satisfy this. Overview. As  in any Tree-based data structure, the M-Tree is composed of Nodes and Leaves. In each node there is a data object that identifies it uniquely and a pointer to a sub-tree where its children reside. Every leaf has several data objects. For each node there is a radius formula_1 that defines a Ball in the desired metric space. Thus, every node formula_2 and leaf formula_3 residing in a particular node formula_4 is at most distance formula_1 from formula_4, and every node formula_2 and leaf formula_3 with node parent formula_4 keep the distance from it. M-Tree construction . Components. An M-Tree has these components and sub-components: Insert. The main idea is first to find a leaf node where the new object belongs. If is not full then just attach it to . If is full then invoke a method to split . The algorithm is as follows: Split. If the split method arrives to the root of the tree, then it choose two routing objects from , and creates two new nodes containing all the objects in original , and store them into the new root. If split methods arrives to a node that is not the root of the  tree, the method choose two new routing objects from , re-arrange every routing object in in two new nodes formula_10 and formula_11, and store these new nodes in the parent node formula_12 of original . The split must be repeated if formula_12 has not enough capacity to store formula_11. The algorithm is as follow: M-Tree Queries. Range Query. A range query is where a minimum similarity/maximum distance value is specified. For a given query object and a maximum search distance , the range query range(Q, r(Q)) selects all the indexed objects such that . Algorithm RangeSearch starts from the root node  and recursively traverses all the paths which cannot be excluded from leading to qualifying objects. k-NN queries. K Nearest Neighbor (k-NN) query takes the cardinality of the input set as an input parameter. For a given query object Q ∈ D and an integer k ≥ 1, the k-NN query NN(Q, k) selects the k indexed objects which have the shortest distance from Q, according to the distance function d.