Advertisement
franciscominajas

ArbolBinario Buscar

Sep 12th, 2013
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.37 KB | None | 0 0
  1. int Buscar(Arbol a, int dat)
  2. {
  3.     pNodo actual = a;
  4.     while(!Vacio(actual))
  5.     {
  6.         if(dat == actual->dato)
  7.         {
  8.             return 1; /* dato encontrado  (2) */
  9.         }
  10.         else if(dat < actual->dato)
  11.         {
  12.             actual = actual->izquierdo;  /* (3) */
  13.         }
  14.         else if(dat > actual->dato)
  15.         {
  16.             actual = actual->derecho; /* (4) */
  17.         }
  18.    }
  19.    return 0; /* No está en árbol (1) */
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement