Binary Search Tree(BST)二叉搜索树的实现-java语言

1.关于二叉搜索树的定义,二叉搜索树是具有以下特征的一棵二叉树:

(1)若一个节点有左孩子,则此节点值大于它左孩子的节点值;

(2)若一个孩子有右孩子,则此节点值不小于它右孩子的节点值;

(3)对其左孩子和右孩子为根节点的子树递归的具有此条性质。

在《COMPUTER ALGORITHMS Introduction to Design and Analysis》一书中对BST的定义如下:

A binary tree in which the nodes have keys keys from an ordered set has the binary search tree property if the key at each node is greater than all the keys in its left subtree and less than or equal to all keys in its right subtree.In this case the binary tree is called a binary search tree.

2.以下代码分成三部分:

(1)BST的创建

(2)BST的查找

(3)BST的遍历输出


完整的代码如下:



你可能感兴趣的:(二叉树,遍历)