www.wikidata.de-de.nina.az
Brent Hashing auch Doppel Hashing mit Brents Algorithmus ist ein Berechnungsverfahren fur eine Hashfunktion das von dem australischen Mathematiker Richard P Brent entwickelt und 1973 publiziert wurde 1 Brent Hashing nutzt ausschliesslich den Platz in der Hashtabelle um neue Eintrage zu speichern und zahlt zu den geschlossenen Hashing Verfahren Brent Hashing wurde ursprunglich entwickelt um das Doppel Hashing Verfahren effizienter zu machen kann aber auf alle geschlossenen Hashing Verfahren mit Erfolg angewendet werden Brent Hashing liefert in der Praxis Effizienzgewinn ist aber mit einem theoretischen Ansatz schwierig zu analysieren 2 Beim offenen Hashing wird an jede Position der Hash Tabelle eine Liste angefugt wahrend beim geschlossenen Hashing auch Hashing mit offener Adressierung genannt eine andere Position in der Hash Tabelle gesucht wird falls die gesuchte Position bereits belegt ist Kollisionsfall Die Reihenfolge in der der Algorithmus die Hash Tabelle nach in Frage kommenden Positionen durchsucht wird als Sondierfolge auch Sondierkette bezeichnet Je kurzer die durchschnittliche Sondierfolge im Kollisionsfall desto effizienter der Algorithmus Im Unterschied zum Doppel Hashing wahlt der Brent Algorithmus aus ob der neue Eintrag oder der schon in der Tabelle vorhandene kollidierende Eintrag verschoben wird Auf diese Weise konnen lange Sondierfolgen vermieden werden und der Algorithmus wird effizienter Inhaltsverzeichnis 1 Kollisionsbehandlung 2 Allgemeine Implementierung 3 Beispiel 3 1 Ablauf des Algorithmus 3 2 Resultierende Tabelle 4 EinzelnachweiseKollisionsbehandlung BearbeitenFur jede Zelle der Hashtabelle wird zusatzlich der Status gespeichert Der Status ist frei belegt oder entfernt falls zuvor ein Element aus dieser Zelle geloscht wurde Ein Element neu soll eingefugt werden und kollidiert mit einem schon in der Tabelle stehenden Element alt Fall 1 h neu ist frei Das neue Element wird auf h neu gespeichert Fall 2 h neu ist belegt und h alt ist frei Das alte Element wird auf h alt verschoben und das neue Element bekommt den Platz des alten Elements Fall 3 h neu ist belegt und h alt ist belegt Es erfolgt ein rekursiver Aufruf der Funktion Erneut muss zwischen den drei Fallen unterschieden werden Das nachste Element alt ist das auf h neu liegende Element Allgemeine Implementierung BearbeitenPseudocode funktion INSERT BRENT HASHING hashtab wert i h wert while hashtab i zustand belegt do neufolgt i h wert mod hashtablange altfolgt i h hashtab i key mod hashtablange if hashtab neufolgt zustand frei oder hashtab altfolgt zustand belegt then i neufolgt else hashtab altfolgt key hashtab i key hashtab altfolgt zustand belegt hashtab i zustand entfernt hashtab i key wert hashtab i zustand belegtBeispiel BearbeitenFolgende Modifikation des Pseudocodes wurde fur das Beispiel benutzt neufolgt i h wert mod hashtablange altfolgt i h hashtab i key mod hashtablange wobei folgende Hashfunktionen genutzt wurden h wert wert mod 13 h wert 1 wert mod 11 Ablauf des Algorithmus Bearbeiten insert 14 i 14 mod 13 1 keine Kollision hashtab i zustand hashtab 1 zustand frei insert 21 i 21 mod 13 8 keine Kollision hashtab i zustand hashtab 8 zustand frei insert 27 i 27 mod 13 1 1 Kollision hashtab i zustand hashtab 1 zustand belegt Indexneuberechnung neufolgt 1 1 27 mod 11 mod 13 8 altfolgt 1 1 14 mod 11 mod 13 10 Prufung auf freien Platz hashtab neufolgt zustand belegt hashtab altfolgt zustand frei Vertauschen der Schlussel hashtab altfolgt key hashtab 10 key hashtab 1 key 14 hashtab i key hashtab 1 key 27 insert 28 i 28 mod 13 2 keine Kollision hashtab i zustand hashtab 2 zustand frei insert 8 i 8 mod 13 8 1 Kollision hashtab i zustand hashtab 8 zustand belegt Indexneuberechnung neufolgt 8 1 8 mod 11 mod 13 12 altfolgt 8 1 21 mod 11 mod 13 10 Prufung auf freien Platz hashtab neufolgt zustand frei hashtab altfolgt zustand belegt Einfugen des Schlussels i neufolgt 12 hashtab i key hashtab 12 key 8 insert 18 i 18 mod 13 5 keine Kollision hashtab i zustand hashtab 5 zustand frei insert 15 i 15 mod 13 2 1 Kollision hashtab i zustand hashtab 2 zustand belegt Indexneuberechnung neufolgt 2 1 15 mod 11 mod 13 10 altfolgt 2 1 28 mod 11 mod 13 8 Prufung auf freien Platz hashtab neufolgt zustand belegt hashtab altfolgt zustand belegt 2 Kollision i neufolgt 10 hashtab i zustand hashtab 10 zustand belegt Indexneuberechnung neufolgt 10 1 15 mod 11 mod 13 5 altfolgt 10 1 14 mod 11 mod 13 6 Prufung auf freien Platz hashtab neufolgt zustand belegt hashtab altfolgt zustand frei Vertauschen der Schlussel hashtab altfolgt key hashtab 6 hashtab i key hashtab 10 14 hashtab i key hashtab 10 15 insert 36 i 36 mod 13 10 1 Kollision hashtab i zustand hashtab 10 zustand belegt Indexneuberechnung neufolgt 10 1 36 mod 11 mod 13 6 altfolgt 10 1 15 mod 11 mod 13 5 Prufung auf freien Platz hashtab neufolgt zustand belegt hashtab altfolgt zustand belegt 2 Kollision i neufolgt 6 hashtab i zustand hashtab 6 zustand belegt Indexneuberechnung neufolgt 6 1 36 mod 11 mod 13 2 altfolgt 6 1 14 mod 11 mod 13 2 Prufung auf freien Platz hashtab neufolgt zustand belegt hashtab altfolgt zustand belegt 3 Kollision i neufolgt 2 hashtab i zustand hashtab 2 zustand belegt Indexneuberechnung neufolgt 2 1 36 mod 11 mod 13 11 altfolgt 2 1 28 mod 11 mod 13 8 Prufung auf freien Platz hashtab neufolgt zustand frei hashtab altfolgt zustand belegt Einfugen des Schlussels i neufolgt 11 hashtab i key hashtab 11 key 36 insert 5 i 5 mod 13 5 1 Kollision hashtab i zustand hashtab 5 zustand belegt Indexneuberechnung neufolgt 5 1 5 mod 11 mod 13 12 altfolgt 5 1 18 mod 11 mod 13 10 Prufung auf freien Platz hashtab neufolgt zustand belegt hashtab altfolgt zustand belegt 2 Kollision i neufolgt 12 hashtab i zustand hashtab 12 zustand belegt Indexneuberechnung neufolgt 12 1 5 mod 11 mod 13 6 altfolgt 12 1 8 mod 11 mod 13 3 Prufung auf freien Platz hashtab neufolgt zustand belegt hashtab altfolgt zustand frei Vertauschen der Schlussel hashtab altfolgt key hashtab 3 key hashtab i key hashtab 12 key 8 hashtab i key hashtab 12 key 5 insert 2 i 2 mod 13 2 1 Kollision hashtab i zustand hashtab 2 zustand belegt Indexneuberechnung neufolgt 2 1 2 mod 11 mod 13 12 altfolgt 2 1 28 mod 11 mod 13 8 Prufung auf freien Platz hashtab neufolgt zustand belegt hashtab altfolgt zustand belegt 2 Kollision i neufolgt 12 hashtab i zustand hashtab 12 zustand belegt Indexneuberechnung neufolgt 12 1 2 mod 11 mod 13 9 altfolgt 12 1 8 mod 11 mod 13 3 Prufung auf freien Platz hashtab neufolgt zustand frei hashtab altfolgt zustand belegt Einfugen des Schlussels i neufolgt 9 hashtab i key hashtab 9 key 2 Resultierende Tabelle Bearbeiten insert 14 21 27 28 8 18 15 36 5 201 14 14 27 27 27 27 27 27 27 272 28 28 28 28 28 28 283 8 845 18 18 18 18 186 14 14 14 1478 21 21 21 21 21 21 21 21 219 210 14 14 14 14 15 15 15 1511 36 36 3612 8 8 8 8 5 5Einzelnachweise Bearbeiten Richard P Brent Reducing the retrieval time of scatter storage techniques In Communications of the ACM Band 16 Heft 2 1973 S 105 109 Dinesh P Mehta Sartaj Sahni Handbook of data structures and applications CRC Press 2004 ISBN 1 58488 435 5 S 9 9 bis 9 13 Abgerufen von https de wikipedia org w index php title Brent Hashing amp oldid 179557239