Implementato HashCode Dictionary via LinearProbing (Open Adress) e Chaining.

This commit is contained in:
2014-05-11 22:47:12 +02:00
parent 597626b34c
commit 53d6129052
19 changed files with 961 additions and 18 deletions

View File

@@ -0,0 +1,31 @@
package com.xgiovio.hash;
/**
* Created with MONSTER.
* User: xgiovio
* Date: 11/05/2014
* Time: 19:25
*/
public class functions {
//http://m.smithworx.com/cs235/notes/view.php?file=extra%20notes/rodham/35-36-com.xgiovio.hash-tables/HashFunctions.java
public static int hash_horner( String key, int tableSize ) {
int hashVal = 0;
for ( int i = 0; i < key.length(); ++i ) {
hashVal = (hashVal * 37) + key.charAt( i );
}
hashVal %= tableSize;
if ( hashVal < 0 ) {
hashVal += tableSize;
}
return hashVal;
}
}