06.05.2013 Views

ALGORITMOS DE BÚSQUEDA Y ORDENACIÓN

ALGORITMOS DE BÚSQUEDA Y ORDENACIÓN

ALGORITMOS DE BÚSQUEDA Y ORDENACIÓN

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>BÚSQUEDA</strong> EN ARCHIVOS<br />

SECUENCIALES OR<strong>DE</strong>NADOS<br />

El algoritmo, en este caso puede ser mejorado:<br />

PROCEDURE buscarord(var f:tarchivoelem;c:tclave;var<br />

elem:tElem; var encontrado:boolean);<br />

{Efecto. Si c está en f entonces encontrado=true y elem es el<br />

elemento buscado, en otro caso encontrado=false}<br />

Var<br />

ultimaclave:clave;<br />

Begin<br />

encontrado:=false;<br />

ultimaclave:=cota superior de las claves;<br />

while not Eof(f) and ultimaclave>c do begin<br />

read(f,elem);<br />

if c:=elem.clave then<br />

encontrado:=true;<br />

ultimaclave:=elem.clave<br />

end; {while}<br />

end; {buscarord}

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!