二叉搜索树实现 in Go语言
用Go实现了下二叉搜索树,还是花了不少时间,在实现中使用的是单向链表,这才算是体会到了双向链表在实现中的优势 package datastructure import ( "container/list" "fmt" ) type BSTree struct { root *Node } type Node struct { left *Node right *Node value int } // NewBSTree 创建树 func NewBSTree() *BSTree { return &BSTree{} } func (t *BSTree) Insert(value int) { var parent *Node z := &Node{value: value} x := t.ro...阅读全文