es.davy.ai

Preguntas y respuestas de programación confiables

¿Tienes una pregunta?

Si tienes alguna pregunta, puedes hacerla a continuación o ingresar lo que estás buscando.

Tag: BINARY-SEARCH-TREE

Llamadas de función recursiva en C++

¿Cuál es la diferencia entre: return(checkBst(root->left, minvalue, root) && checkBst(root->right, root, maxvalue)); y return(checkBst(root->left, minvalue, root)); return(checkBst(root->right, root, maxvalue)); Mi programa completo se ve así: bool checkBst(node *root, node * minvalue, node * maxvalue){ if(root == NULL){ return true; } if((minvalue && root->data <= minvalue->data) || (maxvalue && root->data >= . . . Read more

Teniendo problemas para encontrar la altura de mi primer Árbol de Búsqueda Binaria en JS.

Aquí está mi función constructora y mi método ‘add’… function BinarySearchTree(value) { this.value = value; this.right = null; this.left = null; } BinarySearchTree.prototype.add = function(value) { if (value < this.value) { if (this.left) this.left.add(value); else this.left = new BinarySearchTree(value); } if (value > this.value) { if (this.right) this.right.add(value); else this.right . . . Read more

Método BinarySearch en java

import java.util.*; public class Practice { static ArrayList<integer> populateList(Scanner sc , ArrayList<integer> al){ String l = sc.nextLine(); String arr[] = l.trim().split(“\\s++”); for(int i = 0; i<arr.length; i++){=”” al.add(integer.parseint(arr[i]));=”” }=”” return=”” al;=”” }=”” static=”” void=”” displaylist(string=”” s=”” ,=””></arr.length;><integer> al){ System.out.print(s+ “: “); for(int i = 0; i<al.size(); i++){=”” system.out.print(al.get(i)+=”” );=”” }=”” . . . Read more