golang实现二叉查找树
为简单起见,键值均为整型。 定义接口(tree.go): type Tree interface { Put(k, v int) //新增或修改 Get(k int) int //查询 Delete(k int) //删除 Size() int //树的大小 Min() int //最小键 DeleteMin() //删除最小键 } 二叉查找树(binary_tree.go): //二叉查找树 type BinaryTree struct { root *node n int } //创建节点 func newNode(k, v int) *node { return &node{k: k, v: v, sz: 1} } //创建二叉查找树 func NewBinaryTree() *Bin...阅读全文