Skip to content

Commit

Permalink
Cambios realizados desde ISIS1225-Lib
Browse files Browse the repository at this point in the history
  • Loading branch information
phillipus85 committed Mar 10, 2021
1 parent 53d4b2b commit 9e370f2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions DISClib/DataStructures/chaininghashtable.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ def newMap(numelements, prime, loadfactor, comparefunction):
"""
try:
capacity = nextPrime(numelements//loadfactor)
scale = rd.randint(1, prime-1) + 1
shift = rd.randint(1, prime)
scale = rd.randint(1, prime-1)
shift = rd.randint(0, prime-1)
hashtable = {'prime': prime,
'capacity': capacity,
'scale': scale,
Expand Down Expand Up @@ -318,7 +318,7 @@ def hashValue(table, key):
Calcula un hash para una llave, utilizando el método
MAD : hashValue(y) = ((ay + b) % p) % M.
Donde:
N es el tamaño de la tabla,
M es el tamaño de la tabla, primo
p es un primo mayor a M,
a y b enteros aleatoreos dentro del intervalo [0,p-1], con a>0
"""
Expand All @@ -327,7 +327,7 @@ def hashValue(table, key):
b = table['shift']
p = table['prime']
m = table['capacity']
value = int((abs(h*a + b) % p) % m + 1)
value = int((abs(a*h + b) % p) % m) + 1
return value


Expand Down
8 changes: 4 additions & 4 deletions DISClib/DataStructures/probehashtable.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ def newMap(numelements, prime, loadfactor, comparefunction):
"""
try:
capacity = nextPrime(numelements//loadfactor)
scale = rd.randint(1, prime-1) + 1
shift = rd.randint(1, prime)
scale = rd.randint(1, prime-1)
shift = rd.randint(0, prime-1)
hashtable = {'prime': prime,
'capacity': capacity,
'scale': scale,
Expand Down Expand Up @@ -279,7 +279,7 @@ def hashValue(table, key):
Calcula un hash para una llave, utilizando el método
MAD : hashValue(y) = ((ay + b) % p) % M.
Donde:
N es el tamaño de la tabla,
M es el tamaño de la tabla, primo
p es un primo mayor a M,
a y b enteros aleatoreos dentro del intervalo [0,p-1], con a>0
"""
Expand All @@ -289,7 +289,7 @@ def hashValue(table, key):
b = table['shift']
p = table['prime']
m = table['capacity']
value = int((abs(h*a + b) % p) % m + 1)
value = int((abs(a*h + b) % p) % m) + 1
return value
except Exception as exp:
error.reraise(exp, 'Probe:hashvalue')
Expand Down

0 comments on commit 9e370f2

Please sign in to comment.