public static void NLargestElementInBinarySearchTree_HandlesTreeWithNotEnoughNodes() { var root = BinaryTreeStringUtil.Create("[2] [1 3]"); Assert.That(NLargestElementInBinarySearchTree.FindInOrder(root, 4), Is.EqualTo(null)); Assert.That(NLargestElementInBinarySearchTree.FindQueue(root, 4), Is.EqualTo(null)); }
public static void NLargestElementInBinarySearchTree_HandlesDeepTree() { var root = BinaryTreeStringUtil.Create("[8] [4 12] [2 6 10 14] [1 3 5 7 9 11 13 15]"); Assert.That(NLargestElementInBinarySearchTree.FindInOrder(root, 5).Value, Is.EqualTo(11)); Assert.That(NLargestElementInBinarySearchTree.FindQueue(root, 5).Value, Is.EqualTo(11)); }
public static void NLargestElementInBinarySearchTree_HandlesShallowTree2() { var root = BinaryTreeStringUtil.Create("[2] [1 3]"); Assert.That(NLargestElementInBinarySearchTree.FindInOrder(root, 2).Value, Is.EqualTo(2)); Assert.That(NLargestElementInBinarySearchTree.FindQueue(root, 2).Value, Is.EqualTo(2)); }
public static void NLargestElementInBinarySearchTree_HandlesNormal2() { var root = BinaryTreeStringUtil.Create("[4] [2 6] [1 3 5 7]"); Assert.That(NLargestElementInBinarySearchTree.FindInOrder(root, 4).Value, Is.EqualTo(4)); Assert.That(NLargestElementInBinarySearchTree.FindQueue(root, 4).Value, Is.EqualTo(4)); }
public static void NLargestElementInBinarySearchTree_HandlesLeftTree() { var root = BinaryTreeStringUtil.Create("[4] [2 *] [1 3 * *]"); Assert.That(NLargestElementInBinarySearchTree.FindInOrder(root, 2).Value, Is.EqualTo(3)); Assert.That(NLargestElementInBinarySearchTree.FindQueue(root, 2).Value, Is.EqualTo(3)); }
public static void IsBinarySearchTree_HandlesDeeperValid() { var root = BinaryTreeStringUtil.Create("[4] [1 *] [* 2 * *] [* * * 3 * * * *]"); Assert.That(IsBinarySearchTree.ValidateBinarySearchTree(root), Is.EqualTo(true)); }
public static void IsBinarySearchTree_HandlesDuplicates() { var root = BinaryTreeStringUtil.Create("[4] [1 *] [* 2 * *] [* * 1 3 * * * *]"); Assert.That(IsBinarySearchTree.ValidateBinarySearchTree(root), Is.EqualTo(false)); }
public static void IsBinarySearchTree_HandlesBasicInvalid() { var root = BinaryTreeStringUtil.Create("[4] [2 *] [1 8 * *]"); Assert.That(IsBinarySearchTree.ValidateBinarySearchTree(root), Is.EqualTo(false)); }
public static void IsSuperbalanced_HandlesDeepInbalance2Correctly() { var root = BinaryTreeStringUtil.Create("[1] [2 3] [4 * * 7] [8 * * * * * * *] [16]"); Assert.That(SuperbalancedBinaryTree.IsSuperbalanced(root), Is.EqualTo(false)); }
public static void IsSuperbalanced_HandlesSingleBranchCorrectly() { var root = BinaryTreeStringUtil.Create("[1] [2 *] [4 * * *]"); Assert.That(SuperbalancedBinaryTree.IsSuperbalanced(root), Is.EqualTo(true)); }
public static void IsSuperbalanced_HandlesNoChildrenCorrectly() { var root = BinaryTreeStringUtil.Create("[1]"); Assert.That(SuperbalancedBinaryTree.IsSuperbalanced(root), Is.EqualTo(true)); }
public static void IsSuperbalanced_BasicExample_ReturnsExpected() { var root = BinaryTreeStringUtil.Create("[1] [2 3] [4 5 6 7]"); Assert.That(SuperbalancedBinaryTree.IsSuperbalanced(root), Is.EqualTo(true)); }