public void FindTiltTests() { BinaryTreeTilt obj = new BinaryTreeTilt(); TreeNode node = new TreeNode(1) { left = new TreeNode(2) { }, right = new TreeNode(3) { } }; var x = obj.FindTilt(node);//1 node = new TreeNode(1) { left = new TreeNode(2) { } }; x = obj.FindTilt(node);//2 }
public void BinaryTreeTilt_WhenNotCompleteBinary_ReturnExpected() { var helper = new BinaryTreeTilt(); var root = new TreeNode { val = 4, left = new TreeNode { val = 2, left = new TreeNode { val = 3 }, right = new TreeNode { val = 5 } }, right = new TreeNode { val = 9, left = new TreeNode { val = 7 } } }; var result = helper.FindTilt(root); Assert.That(result, Is.EqualTo(15)); }
public void BinaryTreeTilt_When2Level_ReturnExpected() { var helper = new BinaryTreeTilt(); var root = new TreeNode { val = 1, left = new TreeNode { val = 2, }, right = new TreeNode { val = 3, } }; var result = helper.FindTilt(root); Assert.That(result, Is.EqualTo(1)); }