Hashcode Per Wolde 2002 A L G O R I T M E R & S t r u k t u r Person object: holds: name, phoneNumber -getHashCode: charArray c <- phoneNumber n <- charArray.size hashCode <- c[0]*31^(n-1) + c[1]*31^(n-2)..... c[n-1] return hashCode -setName: this.name <- name -setPhoneNumber: this.phoneNumber <- phoneNumber -getName -getPhoneNumber HashTable: holds: array of persons -hashFunction: index <- (hashCode)mod(arr.size) return index -corrHashFunction: index <- (5 - (hashCode)mod(5)) return index -addItem: hash <- hashFunction(hashCode) corr <- corrHashFunction(hashCode) while array[hash] NOT null THEN hash <- (hash+corr)mod(array.size) array[hash] <- person -find: num <- number to search for hash <- hashFunction(hashCode) corr <- corrHashFunction(hashCode) while array[hash] NOT null THEN if array[hash].phoneNumber is equal to num THEN return array[hash] hash <- (hash+corr)mod(array.size) if done THEN return null -print: FOR zero TO array.size if array[index] NOT null THEN PRINTOUT(array[index])