Advertisement
Guest User

Untitled

a guest
Aug 19th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. // Arreglo para probar
  2. String[] arreglo = { "Chris", "Claire", "Django", "John", "Leon", "Morty", "Rick", "Saul", "Tuco", "Walter" };
  3.  
  4. String busqueda = "Morty";
  5.  
  6. // Probar primero con la recursiva
  7. int indiceDelElementoBuscado = busquedaBinariaRecursiva(arreglo, busqueda, 0, arreglo.length - 1);
  8. System.out.println("[Recursivo] -- El elemento buscado ("
  9. + busqueda
  10. + ") se encuentra en el index "
  11. + indiceDelElementoBuscado);
  12.  
  13. // Ahora con la que usa el ciclo while
  14. indiceDelElementoBuscado = busquedaBinariaConWhile(arreglo, busqueda);
  15. System.out.println("[Con ciclo While] -- El elemento buscado ("
  16. + busqueda
  17. + ") se encuentra en el index "
  18. + indiceDelElementoBuscado);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement