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;
} 

Last updated