06.05.2013 Views

presentación-PDF

presentación-PDF

presentación-PDF

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Código. Doble dirección Hash.<br />

public static int dobleDireccionamiento(int X, int R, int[] A){<br />

int m = A.length;<br />

int dirHash = X%m;<br />

if (A[dirHash] == X) return dirHash;<br />

else {<br />

int dirHash2 = R – (X%R);<br />

int i = 1;<br />

int dirReh = (dirHash + dirHash2)%m;<br />

while ((A[dirReh] != X) && (A[dirReh] != 0) )<br />

{<br />

i++;<br />

dirReh = (dirHash + i*dirHash2)%m;<br />

}<br />

if (A[dirReh] == X) return dirReh;<br />

else return -1;<br />

}<br />

}

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

Saved successfully!

Ooh no, something went wrong!