> For the complete documentation index, see [llms.txt](https://jenhsuan.gitbook.io/algorithm/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jenhsuan.gitbook.io/algorithm/algorithms-in-a-nutshell/meet-binary-tree-a-hierarchical-data-structure.md).

# Binary tree

## 1.Introduction

* The order is not important
* A tree is typical used to present hierarchical structure
* General tree
  * Can have any number of child node
  * Less useful
* Binary tree
  * Can have 0, 1, 2 child node
* Terminology
  * Root, edge, leaf, siblings(same level, same distance from the root node), ancestor, descendent
  * The root node: is an ancestor of every nodes

## 2.Code

* Tree data structure

```
public static class Node<T>
{
    private T data;
    private Node<T> leftChild;
    private Node<T> rightChild;
} 
```
