Esempio n. 1
0
        public static long Sum(long leftKey, long rightKey, BinarySearchTreeNode root)
        {
            long results = 0;
            var  node    = Find(leftKey, root);

            while (node != null && node.Key <= rightKey)
            {
                if (node.Key >= leftKey)
                {
                    results += node.Key;
                }

                node = BinarySearchTree.Next(node);
            }
            return(results);
        }
Esempio n. 2
0
 private static BinarySearchTreeNode Delete(BinarySearchTreeNode node)
 {
     Splay(BinarySearchTree.Next(node));
     Splay(node);
     return(BinarySearchTree.Delete(node));
 }