public void TestRotateRightLeft() { MyAVLTREE <int, string> myAVLTREE = new MyAVLTREE <int, string>(); myAVLTREE.Add(3, ""); myAVLTREE.Add(5, ""); myAVLTREE.Add(4, ""); Assert.That(myAVLTREE.Root.Key, Is.EqualTo(4)); Assert.That(myAVLTREE.Root.Left.Key, Is.EqualTo(3)); Assert.That(myAVLTREE.Root.Right.Key, Is.EqualTo(5)); Assert.That(Math.Log(myAVLTREE.Count() + 1, 2) <= myAVLTREE.Height(), Is.EqualTo(true)); }
private int MaxHeight <Key, Value>(MyAVLTREE <Key, Value> tree) where Key : IComparable <Key> { return((int)Math.Floor(1.44 * Math.Log(tree.Count() + 2, 2) - .328)); }