Hashed Array Tree - Expansions and Size Reductions

Expansions and Size Reductions

In a usual dynamic array geometric expansion scheme, the array is reallocated as a whole sequential chunk of memory with the new size a double of its current size (and the whole data is then moved to the new location). This ensures O(1) amortized operations at a cost of O(n) wasted space, as the enlarged array is filled to the half of its new capacity.

When a hashed array tree is full, its directory and leaves must be restructured to twice their prior size to accommodate additional append operations. The data held in old structure is then moved into the new locations. Only one new leaf is then allocated and added into the top array which thus becomes filled only to a quarter of its new capacity. All the extra leaves are not allocated yet, and will only be allocated when needed, thus wasting only O(n1/2) of storage.

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, without resizing the leaves. Further optimizations include adding new leaves without resizing, growing the directory array as needed, possibly through geometric expansion. This would eliminate the need for data copying completely, at the cost of making the wasted space O(n), with a small coefficient, and only performing restructuring when a set threshold overhead is reached.

Read more about this topic:  Hashed Array Tree

Famous quotes containing the words size and/or reductions:

    It is very considerably smaller than Australia and British Somaliland put together. As things stand at present there is nothing much the Texans can do about this, and ... they are inclined to shy away from the subject in ordinary conversation, muttering defensively about the size of oranges.
    Alex Atkinson, British humor writer. repr. In Present Laughter, ed. Alan Coren (1982)

    The work was like peeling an onion. The outer skin came off with difficulty ... but in no time you’d be down to its innards, tears streaming from your eyes as more and more beautiful reductions became possible.
    Edward Blishen (b. 1920)