M-tree
In computer science, M-trees are tree data structures, which means they are ways of organizing information in a branching shape. They are similar to R-trees and B-trees, which are other kinds of tree structures. M-trees are built using a metric, a way of measuring how far apart things are, and they rely on the triangle inequality to search efficiently. This helps them answer two kinds of questions: range queries, which look for items within a certain distance, and k-nearest neighbor (k-NN) queries, which look for the closest items to a given point.
M-trees can work well in many situations. However, they also have some weaknesses. The tree can have large overlap, meaning that parts of it cover the same space, and there is no clear strategy for how to best avoid this overlap.
Another limit is that M-trees can only be used with distance functions that follow the triangle inequality. Many advanced ways of comparing how different things are, which are used in information retrieval, do not follow this rule, so M-trees cannot be used with them.
Overview
Like other tree-based data structures, an M-tree is made of nodes and leaves. Each node has a data object that uniquely identifies it, along with a pointer to a sub-tree where its children are kept. Every leaf holds several data objects. Each node also has a radius, r, which defines a ball in the space being used. This means that every node and leaf inside a node is at most distance r from that node, and each child keeps its distance from its parent.
M-tree construction
An M-tree has two kinds of nodes. Non-leaf nodes hold routing objects, which point to smaller parts of the tree. Leaf nodes hold the actual objects. Each routing object and each object also keeps track of its parent and its distance from that parent.
To add a new object, the tree first finds the leaf node where the object belongs. If that node has room, the object is simply attached to it. If the node is full, the tree splits it. When a split reaches the top of the tree, two routing objects are chosen from the node, and two new nodes are created to hold all of its objects, which are then stored in a new root. When a split happens in a node that is not the root, two new routing objects are chosen, the objects are divided between two new nodes, and those nodes are stored in the parent node. If the parent does not have room for the second new node, the split is repeated.
M-tree queries
A range query sets a maximum distance. For a query object Q and a largest search distance r(Q), the range query finds all the indexed objects Oj that are no farther from Q than r(Q). The search starts at the top of the tree, called the root node, and checks every path that could still lead to matching objects.
A k-nearest neighbor (k-NN) query takes a number k as its input. For a query object Q and a whole number k that is at least 1, it finds the k indexed objects that are closest to Q, based on the distance function.

Quiz time!
5 questions about M-tree
What is an M-tree?
Keep exploring
This article is a child-friendly adaptation of the Wikipedia article on M-tree, available under CC BY-SA 4.0.
Images from Wikimedia Commons. Tap any image to view credits and license.