Jump to content

Hashed array tree

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Queenmomcat (talk | contribs) at 16:25, 16 October 2008 (typos). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

In computer science, a hashed array tree (HAT) is a dynamic array algorithm invented by Edward Sitarski in 1996. [1] Whereas simple dynamic array data structures based on geometric expansion waste linear (Ω(n)) space, where n is the number of elements in the array, hashed array trees waste only order n1/2 storage space. It can perform indexing in constant (O(1)) time, but indexing is not as quick in practice as for simple dynamic arrays. The algorithm has O(1) amortized performance when appending a series of objects to the end of a hashed array tree. Contrary to its name, it does not use hash functions.

A full Hashed Array Tree with 16 elements

Definitions

As defined by Sitarski, a hashed array tree has a top-level directory containing a power of two number of leaf arrays. All leaf arrays are the same size as the top-level directory. This structure superficially resembles a hash table with array-based collision chains, which is the basis for the name hashed array tree. A full hashed array tree can hold m2 elements, where m is the size of the top-level directory.[1]

Expansions and size reductions

When a hashed array tree is full, its directory and leaves must be restructured to twice its prior size to accommodate additional append operations. There are multiple alternatives for reducing size: when a Hashed Array Tree is one eighth full, it can be restructured to a smaller, half-full hashed array tree; another option is only freeing unused leaf arrays.

Brodnik et al. [2] presented a dynamic array algorithm with a similar space wastage profile to hashed array trees. Brodnik's implementation retains previously allocated leaf arrays, with a more complicated address calculation function as compared to hashed array trees.

See also

References

  1. ^ a b Sitarski, Edward (September 1996), "HATs: Hashed array trees", Dr. Dobb's Journal, 21 (11) {{citation}}: |contribution= ignored (help)
  2. ^ Brodnik, Andrej; Carlsson, Svante; Sedgewick, Robert; Munro, JI; Demaine, ED (Technical Report CS-99-09), Resizable Arrays in Optimal Time and Space (PDF), Department of Computer Science, University of Waterloo {{citation}}: Check date values in: |date= and |year= / |date= mismatch (help)