// Balance - Re-balance the tree nodes so that the searches can be even more efficient
Re-balance the tree nodes so that the searches can be even more efficient
// Balance - Re - balance the tree nodes so that the searches can be even more efficient
func (lt *LinkedTreeNode) Balance(size int64) (*LinkedTreeNode, int64, error) {
	list := []*LinkedTreeNode{}
	node, err := lt.GetFirstNode()
	if err != nil {
		return nil, 0, err
	}
	var nodeCount int64 = 0
	for node != nil {
		node.Parent = nil
		node.Left = nil
		node.Right = nil
		if lt.Deleted == false {
			list = append(list, node)
			nodeCount++
		}
		node = node.Next
	}
	node, err = lt.balance(list)
	return node, nodeCount, err
}
func ( lt * LinkedTreeNode ) Balance ( size int64 ) ( * LinkedTreeNode , int64 , error ) { list := [ ] * LinkedTreeNode { } node , err := lt . GetFirstNode ( ) if err != nil { return nil , 0 , err } var nodeCount int64 = 0 for node != nil { node . Parent = nil node . Left = nil node . Right = nil if lt . Deleted == false { list = append ( list , node ) nodeCount ++ } node = node . Next } node , err = lt . balance ( list ) return node , nodeCount , err }
Re-balance the tree nodes so that the searches can be even more efficient
Re - balance the tree nodes so that the searches can be even more efficient
// list := make([]*LinkedTreeNode, size)