Tree data structure

HomePage | Recent changes | View source | Discuss this page | Page history | Log in |

Printable version | Disclaimers | Privacy policy

A tree is a hierarchical data structure made up of nodes. Each node has zero or more child nodes, which are below it in the tree (in computer science, unlike in nature, trees grow down, not up). The node of which a node is a child is called its parent node. A child has only one parent. If the tree has a single node without a parent, this node is called the root node (or root). Nodes with no children are called leaf nodes.

There are many different ways to represent trees; common representations represent the nodes as records allocated on the heap with pointers to their children, their parents, or both, or as items in an array, with relationships between them determined by their positions in the array.

See also binary tree, heap, ordered tree data structure, hierarchical tree structure.