Tree with two fork tree

Source: Internet
Author: User
Tags in degrees

Tree definition

A tree is a finite set of n (n≥0) nodes, which is either an empty tree (n=0), or a non-empty tree

A non-empty tree T satisfies the following conditions:

(1) There is only one node called the root;

(2) The remaining nodes outside the root node can be divided into m (m>0) complementary intersecting finite set t1,t2,... Tm, where each set is itself a tree, and is called the root subtree.

                         空树

                       一般的树
Basic terminology

Root ——— is the root node (no precursor).

Leaf ——— i.e. Terminal node (no successor)

Forest ——— refers to the collection of M-disjoint trees

Ordered tree ——— nodes are ordered from left to right and cannot be interchanged.

The unordered tree ——— nodes of each subtree are interchangeable positions.

The parent ——— the upper node (direct precursor).

Child ——— The root of the sub-tree of the lower node (direct successor)

Brothers ——— the same parents under the same node (children are called Brothers each other)

Cousins ——— where both parents are on the same level (but not the same parent)

Ancestors ——— all nodes from the root to the branches of the node.

Descendants ——— any node of the lower sub-species of the node.

Node ——— The data element of the tree

The degree of the node ——— the number of sub-trees connected to the node

The level of the node ——— the number of layers from the root to the node (the root node counts the first layer)

Terminal node ——— a node with a degree of 0, that is, a leaf.

Branch nodes ——— nodes that are not 0 in degrees (also known as internal nodes).

The degree of the tree ——— the maximum value in all node degrees

The depth ——— of the tree refers to the maximum number of layers (or heights) in all nodes.

Two-fork Tree

Binary tree is a special kind of tree structure, if the ordinary tree does not turn into a binary tree, the operation is difficult to achieve

Why should we focus on the binary tree?
    • Binary tree structure is the simplest, the most regular

    • All trees can be converted to the only corresponding two-fork tree, without losing its generality.

Defined:

Each node has a maximum of two subtrees.

Basic Features:
    • The node's degree is less than or equal to 2.
    • Ordered tree (sub-tree is orderly and cannot be reversed)

                           二叉树的五种形态
Properties of Binary Tree 1: There are 2^i-1 nodes (i≥1) on the first layer of a non-empty binary tree. Property 2: If the depth of the empty tree is specified to be 0, then the two fork tree with a depth of K has a maximum of (2^k)-1 nodes.

(k≥0).

Property 3: The depth k of a complete binary tree with n nodes is log2n+1. Property 4: For a non-empty binary tree, if the number of nodes with a degree of 0 is n0, the number of nodes with a degree of 2 is N2, then there is n0= n2+1. Property 5: For a complete binary tree with n nodes, if all nodes are numbered from top to bottom and from left to right, the nodes with the ordinal I are:
    1. If i>1, then the parent node of the node with the sequence number i is I/2 ("/" for division), and if I=1, the node is the root node, with no parent nodes.

    2. If 2i≤n, the left child node of the node is numbered 2i, and if 2i>n, the node has no left child.

    3. If 2i+1≤n, then the node of the right child node is 2i+1, if 2i+1>n, then the node has no right child.

Full two fork tree: a two-prong tree with a depth of K and a 2k-1 node. (meaning that the tree is full of points of closure)

A complete binary tree: A two-tree with a depth of k, with n nodes, when and only if each of its nodes corresponds to a node one by one in a full two-tree with a depth of k from 1 to n (meaning that only the last leaf is dissatisfied, and all is concentrated on the left)

                    Unfinished, see the next

Tree with two fork tree

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.