HashTables–1帜褪众尹舵姥得硕捞叹吟谐力错炕阔勾昆垛残恕汪壮血裁竣寅驻朴蚌摩闰哈希算法哈希算法DictionaryDictionary:Dynamic-,Search,:--:,Fall2003Direct-addressTablesDirect-(1),Fall2003HashTablesNotation:U––Setofkeysactuallystoredinthedictionary.|K|=,Arraysarenotpractical.|K|<<|U|.Useatableofsizeproportionalto|K|–,welosethedirect-,Fall2003HashingHashfunctionh:MappingfromUtotheslotsofahashtableT[0..m–1].h:U{0,1,…,m–1}Witharrays,keykmapstoslotA[k].Withhashtables,keykmapsor“hashes”toslotT[h[k]].h[k],Fall2003Hashing0m–1h(k1)h(k4)h(k2)=h(k5)h(k3)U(universeofkeys)K(actualkeys)p122,Fall2003IssueswithHashingMultiplekeyscanhashtothesameslot–-(n),plexityofӨ(1).p122,Fall2003MethodsofResolutionChaining:(拉链法)(线性探测法),useasystematic(consistent)–p122,Fall2003CollisionResolutionbyChaining0m–1h(k1)=h(k4)h(k2)=h(k5)=h(k6)h(k3)=h(k7)U(universeofkeys)K(actualkeys)k1k2k3k5k4k6k7k8h(k8)p122,Fall2003k2CollisionResolutionbyChaining0m–1U(unive
哈希算法 来自淘豆网m.daumloan.com转载请标明出处.