
findMin y findMax . Estos métodos deben devolver el valor mínimo y máximo retenido en el árbol de búsqueda binario (no se preocupe por agregar valores al árbol por ahora, hemos agregado algunos en el fondo). Si te quedas atascado, reflexiona sobre el invariante que debe ser cierto para los árboles de búsqueda binarios: cada subárbol izquierdo es menor o igual que su principal y cada subárbol derecho es mayor o igual que su principal. Digamos también que nuestro árbol solo puede almacenar valores enteros. Si el árbol está vacío, cualquiera de los métodos debe devolver null . BinarySearchTree existe.
testString: 'assert((function() { var test = false; if (typeof BinarySearchTree !== "undefined") { test = new BinarySearchTree() }; return (typeof test == "object")})(), "The BinarySearchTree data structure exists.");'
- text: El árbol de búsqueda binario tiene un método llamado findMin .
testString: 'assert((function() { var test = false; if (typeof BinarySearchTree !== "undefined") { test = new BinarySearchTree() } else { return false; }; return (typeof test.findMin == "function")})(), "The binary search tree has a method called findMin.");'
- text: El árbol de búsqueda binario tiene un método llamado findMax .
testString: 'assert((function() { var test = false; if (typeof BinarySearchTree !== "undefined") { test = new BinarySearchTree() } else { return false; }; return (typeof test.findMax == "function")})(), "The binary search tree has a method called findMax.");'
- text: El método findMin devuelve el valor mínimo en el árbol de búsqueda binario.
testString: 'assert((function() { var test = false; if (typeof BinarySearchTree !== "undefined") { test = new BinarySearchTree() } else { return false; }; if (typeof test.findMin !== "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.findMin() == 1; })(), "The findMin method returns the minimum value in the binary search tree.");'
- text: El método findMax devuelve el valor máximo en el árbol de búsqueda binario.
testString: 'assert((function() { var test = false; if (typeof BinarySearchTree !== "undefined") { test = new BinarySearchTree() } else { return false; }; if (typeof test.findMax !== "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.findMax() == 87; })(), "The findMax method returns the maximum value in the binary search tree.");'
- text: Los métodos findMin y findMax devuelven un null para un árbol vacío.
testString: 'assert((function() { var test = false; if (typeof BinarySearchTree !== "undefined") { test = new BinarySearchTree() } else { return false; }; if (typeof test.findMin !== "function") { return false; }; if (typeof test.findMax !== "function") { return false; }; return (test.findMin() == null && test.findMax() == null) })(), "The findMin and findMax methods return null for an empty tree.");'
```