Open KevinACoder opened 5 years ago
func BstTest(n int) {
defer Wg.Done()
//keys := []string{"A", "B", "C", "D", "E"}
//vals := []int{1, 2, 3, 4, 5}
var keys []string
var vals []int
idx := 0
for c := 'A'; c < 'Z'; {
keys = append(keys, string(c))
vals = append(vals, idx)
idx++
c = rune(int('A') + idx)
}
rbTree := NewRBTree()
avlTree := NewAVLTree()
for i := range keys {
rbTree.InsertRBNode(keys[i], vals[i])
avlTree.BalancedInsert(keys[i], vals[i])
}
fmt.Println(rbTree.InorderRB())
fmt.Println("balanced", rbTree.IsBalanced(), avlTree.IsBalanced())
fmt.Println("height", rbTree.GetHeight(), avlTree.GetHeight())
fmt.Println("level order", rbTree.Levelorder(), avlTree.LevelOrder())
fmt.Println("inorder order", rbTree.InorderRB(), avlTree.Inorder())
}