A tree structure is a way of representing the hierarchical nature of a structure in a graphical form. It is named a "tree structure" because the graph looks a bit like a tree, even though the tree is generally shown upside down compared with a real tree; that is to say with the root at the top and the leaves at the bottom.
In terms of graph theory, a tree can be described as a "connected directed acyclic graph." A collection of unconnected tree structures is sometimes described by graph theorists as a "forest." See tree (graph theory) for more mathematical background behind a tree structure.
Illustration: A tree structure showing the possible hierarchical organization of an encyclopedia. This specific example happens to be a complete binary tree, which means all nodes have exactly zero or two child nodes.
The lines connecting elements are called ''branches," the elements themselves are called "nodes." Nodes without children are called "end-nodes" or "leaves."
The names of relationships between nodes are modeled after family relations. In computer sciences, traditionally only names for male family members have been used. In linguistics, the names of female family members are used. It is said that this was an express counter movement to the traditional naming convention, started by the female students of linguist Noam Chomsky. However, nowadays, in computer science at least, the gender-neutral names "parent" and "child" have largely displaced the older "father" and "son" terminology.
The starting node is often called the "root."
- A node is a "parent" of another node if it is one step higher in the hierarchy and closer to the root node.
- "Sibling" ("brother" or "sister") nodes share the same parent nodes.
- A node that is connected to all lower-level nodes is called an "ancestor."
Tree structures are used to depict all kinds of taxonomic knowledge, such as family trees, the Evolutionary tree, the grammatical structure of a language (the famous example being S -> NP VP, meaning a sentence is a noun phrase and a verb phrase), the way web pages are logically ordered in a web site, et cetera.
Trees have a number of interesting properties:
- The root node, i.e., the base node, is an ancestor of all the other nodes.
- In a tree structure there is one and only one path from any point to any other point.
Examples of tree structures