Lably
Skip to content

Bit array

Array data structure that compactly stores bits

  • 22 min read
  • 8 chapters

Related on Lably

Through Word (computer architecture), Matrix multiplication and Bitwise operation

Definition

A bit array is a mapping from some domain (almost always a range of integers) to values in the set {0,1}. The values can be interpreted as dark/light, absent/present, locked/unlocked, valid/invalid, et cetera. The point is that there are only two possible values, so they can be stored in one bit. As with other arrays, the access to a single bit can be managed by applying an index to the array. Assuming its size (or length) to be n bits, the array can be used to specify a subset of the domain (e.g. {0,1,2,...,n−1}), where a 1-bit indicates the presence and a 0-bit the absence of a number in the set. This set data structure uses about nw words of space, where w is the number of bits in each machine word. Whether the least significant bit (of the word) or the most significant bit indicates the smallest-index number is largely irrelevant, but the former tends to be preferred (on little-endian machines).

A finite binary relation may be represented by a bit array called a logical matrix. In the calculus of relations, these arrays are composed with matrix multiplication where the arithmetic is Boolean, and such a composition represents composition of relations.

Sign in to keep reading

7 more chapters are free with a Lably account.

More in Computing and communication