Hash array mapped trie
PARID VAROSHI
A hash array mapped trie (HAMT) is an implementation of an
associative array that combines the characteristics of a hash
table and an array mapped trie. It is a refined version of the
more general notion of a hash tree.
 A HAMT is an array mapped trie where the keys are first hashed to ensure an
even distribution of keys and a constant key length.
 In a typical implementation of HAMT's array mapped trie, each node contains
a table with some fixed number N of slots with each slot containing either a
nil pointer or a pointer to another node. N is commonly 32. As allocating
space for N pointers for each node would be expensive, each node instead
contains a bitmap which is N bits long where each bit indicates the presence
of a non-nil pointer. This is followed by an array of pointers equal in length to
the number of ones in the bitmap, (its Hamming weight).
Advantages of HAMTs
 The hash array mapped trie achieves almost hash table-like speed while using
memory much more economically. Also, a hash table may have to be periodically
resized, an expensive operation, whereas HAMTs grow dynamically. Generally,
HAMT performance is improved by a larger root table with some multiple of N
slots; some HAMT variants allow the root to grow lazily with negligible impact on
performance.
IMPLEMENTATION :
 Implementation of a HAMT involves the use of the population count function,
which counts the number of ones in the binary representation of a number. This
operation is available in many instruction set architectures, but it is available in
only some high-level languages. Although population count can be implemented in
software in O(1) time using a series of shift and add instructions, doing so may
perform the operation an order of magnitude slower
REFERENCES:
 https://idea.popcount.org/2012-07-25-introduction-to-hamt/
 https://en.wikipedia.org/wiki/Hash_array_mapped_trie

Hash array mapped trie

  • 1.
    Hash array mappedtrie PARID VAROSHI
  • 2.
    A hash arraymapped trie (HAMT) is an implementation of an associative array that combines the characteristics of a hash table and an array mapped trie. It is a refined version of the more general notion of a hash tree.  A HAMT is an array mapped trie where the keys are first hashed to ensure an even distribution of keys and a constant key length.  In a typical implementation of HAMT's array mapped trie, each node contains a table with some fixed number N of slots with each slot containing either a nil pointer or a pointer to another node. N is commonly 32. As allocating space for N pointers for each node would be expensive, each node instead contains a bitmap which is N bits long where each bit indicates the presence of a non-nil pointer. This is followed by an array of pointers equal in length to the number of ones in the bitmap, (its Hamming weight).
  • 3.
    Advantages of HAMTs The hash array mapped trie achieves almost hash table-like speed while using memory much more economically. Also, a hash table may have to be periodically resized, an expensive operation, whereas HAMTs grow dynamically. Generally, HAMT performance is improved by a larger root table with some multiple of N slots; some HAMT variants allow the root to grow lazily with negligible impact on performance. IMPLEMENTATION :  Implementation of a HAMT involves the use of the population count function, which counts the number of ones in the binary representation of a number. This operation is available in many instruction set architectures, but it is available in only some high-level languages. Although population count can be implemented in software in O(1) time using a series of shift and add instructions, doing so may perform the operation an order of magnitude slower
  • 7.