From 6c5304980ddfabc3547ca01d3aeaf51af2e4a1ac Mon Sep 17 00:00:00 2001 From: ngschaider Date: Fri, 27 Nov 2020 05:33:45 +0100 Subject: [PATCH] fix(learn): type checking and additional test for isBalanced binary search tree (#40323) * Update find-the-minimum-and-maximum-height-of-a-binary-search-tree.md * fixed binary search tree values for balanced tree test * Apply suggestions from code review Co-authored-by: Nicholas Carrigan (he/him) Co-authored-by: Nicholas Carrigan (he/him) --- ...he-minimum-and-maximum-height-of-a-binary-search-tree.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/curriculum/challenges/english/10-coding-interview-prep/data-structures/find-the-minimum-and-maximum-height-of-a-binary-search-tree.md b/curriculum/challenges/english/10-coding-interview-prep/data-structures/find-the-minimum-and-maximum-height-of-a-binary-search-tree.md index db08d488a1..6f0734d97d 100644 --- a/curriculum/challenges/english/10-coding-interview-prep/data-structures/find-the-minimum-and-maximum-height-of-a-binary-search-tree.md +++ b/curriculum/challenges/english/10-coding-interview-prep/data-structures/find-the-minimum-and-maximum-height-of-a-binary-search-tree.md @@ -36,8 +36,10 @@ tests: testString: assert((function() { var test = false; if (typeof BinarySearchTree !== 'undefined') { test = new BinarySearchTree() } else { return false; }; if (typeof test.findMaxHeight !== 'function') { return false; }; test.add(4); test.add(1); test.add(7); test.add(87); test.add(34); test.add(45); test.add(73); test.add(8); return (test.findMaxHeight() == 5); })()); - text: An empty tree should return a height of -1. testString: assert((function() { var test = false; if (typeof BinarySearchTree !== 'undefined') { test = new BinarySearchTree() } else { return false; }; if (typeof test.findMaxHeight !== 'function') { return false; }; return (test.findMaxHeight() == -1); })()); - - text: The isBalanced method should return true if the tree is a balanced binary search tree. - testString: assert((function() { var test = false; if (typeof BinarySearchTree !== 'undefined') { test = new BinarySearchTree() } else { return false; }; if (typeof test.isBalanced !== 'function') { return false; }; test.add(4); test.add(1); test.add(7); test.add(87); test.add(34); test.add(45); test.add(73); test.add(8); return !test.isBalanced(); })()); + - text: The isBalanced method should return false if the tree is an unbalanced binary search tree. + testString: assert((function() { var test = false; if (typeof BinarySearchTree !== 'undefined') { test = new BinarySearchTree() } else { return false; }; if (typeof test.isBalanced !== 'function') { return false; }; test.add(4); test.add(1); test.add(7); test.add(87); test.add(34); test.add(45); test.add(73); test.add(8); return test.isBalanced() === false; })()); + - text: The isBalanced method should return true if the tree is a balanced binary search tree. + testString: assert((function() { var test = false; if (typeof BinarySearchTree !== 'undefined') { test = new BinarySearchTree() } else { return false; }; if (typeof test.isBalanced !== 'function') { return false; }; test.add(10); test.add(3); test.add(22); test.add(1); test.add(4); test.add(17); test.add(32); return test.isBalanced() === true; })()); ```