非线性结构
树的术语:
节点的度——节点的子树点个数
树的度——树的所有节点中最大的度数
任何一颗树最后都可以用二叉树(每个节点的子节点最多只有2个)模拟
二叉搜索树(BST, Binary Search Tree),又称为二叉排序树或二叉找树
查找效率高
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>树结构</title>
</head>
<body>
<script>
//封装二叉搜索树
function BinarySearchTree(){
function Node(key){
this.key = key
this.left = null
this.right = null
}
//属性
this.root = null
//方法
BinarySearchTree.prototype.insert = function(key){
var newNode = new Node(key)
if(this.root === null){
this.roo