treesarrays
Treesarrays is a term used in computer science to refer to data structures and representations that store hierarchical tree structures within arrays or as collections of arrays. It covers methods that replace or augment pointer-based trees with contiguous memory layouts to improve locality, serialization, or interoperability with low-level systems.
Common representations include:
- Array-based binary trees: used for complete binary trees such as binary heaps, where a node at
- Parent array: a single array parent[] stores the index of each node’s parent; the root has a
- First-child/next-sibling representation: stores firstChild[i] and nextSibling[i] in arrays to traverse a general tree, effectively encoding a
- Adjacency arrays: use a head[] array for nodes and an edge array with next[] pointers to enumerate
Advantages include improved memory locality, simpler serialization, and compact storage for static trees or trees with
Typical applications are priority queues implemented as heaps, storage of static hierarchical data for efficient traversal,