Monoid - Monoids in Computer Science

Monoids in Computer Science

In computer science, many abstract data types can be endowed with a monoid structure. In a common pattern, a sequence of elements of a monoid is "folded" or "accumulated" to produce a final value. For instance, many iterative algorithms need to update some kind of "running total" at each iteration; this pattern may be elegantly expressed by a monoid operation. Alternatively, the associativity of monoid operations ensures that the operation can be parallelized by employing a prefix sum or similar algorithm, in order to utilize multiple cores or processors efficiently.

Given a sequence of values of type M with identity element and associative operation, the fold operation is defined as follows:

In addition, any data structure can be 'folded' in a similar way, given a serialization of its elements. For instance, the result of "folding" a binary tree might differ depending on pre-order vs. post-order tree traversal.

Read more about this topic:  Monoid

Famous quotes containing the words computer and/or science:

    The Buddha, the Godhead, resides quite as comfortably in the circuits of a digital computer or the gears of a cycle transmission as he does at the top of a mountain or in the petals of a flower.
    Robert M. Pirsig (b. 1928)

    For twenty-five centuries, Western knowledge has tried to look upon the world. It has failed to understand that the world is not for the beholding. It is for hearing. It is not legible, but audible. Our science has always desired to monitor, measure, abstract, and castrate meaning, forgetting that life is full of noise and that death alone is silent: work noise, noise of man, and noise of beast. Noise bought, sold, or prohibited. Nothing essential happens in the absence of noise.
    Jacques Attali (b. 1943)