// breadth-first search
// levelOrderTraverse traverse by level-order.
breadth-first search
levelOrderTraverse traverse by level-order.
// breadth - first search // levelOrderTraverse traverse by level - order .
func (b *BST) levelOrderTraverse() {
	if b != nil {
		queue := []*Node{b.Root}
		for len(queue) > 0 {
			currentNode := queue[0]
			fmt.Printf("%d ", currentNode.Key)
			queue = queue[1:]
			if currentNode.Left != nil {
				queue = append(queue, currentNode.Left)
			}
			if currentNode.Right != nil {
				queue = append(queue, currentNode.Right)
			}
		}
	}
}
func ( b * BST ) levelOrderTraverse ( ) { if b != nil { queue := [ ] * Node { b . Root } for len ( queue ) > 0 { currentNode := queue [ 0 ] fmt . Printf ( " " , currentNode . Key ) queue = queue [ 1 : ] if currentNode . Left != nil { queue = append ( queue , currentNode . Left ) } if currentNode . Right != nil { queue = append ( queue , currentNode . Right ) } } } }
breadth-first search
levelOrderTraverse traverse by level-order.
breadth - first search levelOrderTraverse traverse by level - order .