PHP interview finishing (c) the data base structure - tree

2019-09-01 21:25:18

 

PHP graduating students, on the Internet read a lot of interviews and information related stuff, here recorded, some places may be related to the original others, but at that time did not have time to add notes, if offended, please tell me, I will add the source is acknowledged. (Learning on the way there are a lot of mistakes, and ignoring the place, I hope you will correct me, thank you !!!)

 

(Wikipedia: https://zh.wikipedia.org/wiki/%E6%A0%91_(%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84) )

 

 

 

 

 

 

 

 

 

 

 (Definition of the book)

Binary: n is a finite set of nodes, the set or dimensional empty set (empty binary), or consists of a root and two disjoint, called binary left subtree and right subtree of the root node composition.

Features:

  • Each node has at most two subtrees
  • Binary tree is ordered

Full Binary: In a binary tree, the branch node if there are all left subtree and right subtree, and all sub-field are on the same layer, so that a binary tree is called a full binary tree.

Features:

  • Leaves only appear at the next level
  • Only degree is 0 or nodes 2

Complete binary tree: a binary tree with n nodes by sequence number, if the number i (1≤ i ≤ n) is a full binary tree nodes at the same depth in the position number in the binary tree node i in identical, Fengyun called binary tree complete binary tree.

Features:

  • Leaf nodes can only appear at the lower layers, and the lowermost leaf nodes are concentrated in discrete positions on the left side binary
  • If there is a degree of nodes 1, there may be only one, and that only the left child node

The binary tree traversal operations:
before the postorder traversal around the root, root left and right around the root

 

Binary search tree (binary search tree, ordered binary tree, binary tree sort): it refers to an empty tree or a tree with the following properties:

  1. If the left subtree of any node is not empty, then the value of the left sub-tree, all the nodes are less than the value of the root node;
  2. If the right subtree of any node is not empty, the right subtree are greater than values ​​of all the nodes of the root node and its value;
  3. Any node of the left and right subtrees are also binary search tree;
  4. There is no equivalent key node.

 

Balanced binary tree: is a structurally balanced binary search tree , the leaf nodes, i.e., the height difference absolute value is not more than 1, and the left and right sub-trees are a balanced binary tree.

Red-black tree: a special kind of binary search tree

 

 

 

 

Being the first record definition, understanding and implementation delayed ..................

 

Guess you like

Origin www.cnblogs.com/zhaoguofeng/p/11443725.html