Multiset

A multiset is a modification of the concept of a set that allows for multiple instances of the same element. Unlike regular sets where each element appears exactly once, multisets track the multiplicity (number of occurrences) of each element.
Formally, a multiset over a universe (base set) is defined via its “multiplicity function”:

Key properties:

  • Order is irrelevant (like regular sets)
  • Elements can appear multiple times
  • The multiplicity of each element is significant
  • Elements can have zero occurrences

Notation: If is a multiset, we can denote it as:

  • (listing all occurrences)
  • (using superscripts for multiplicity)

The cardinality of a multiset includes all instances:

Examples

The string “hello” as a multiset:
Chemical formula H₂O as a multiset:

Permuting a multiset is like permuting a string of characters:
There are ways to permute a set with elements, but for a multiset, we need divide by the amount of permutations of equal elements whose order doesn’t matter (eliminating all those sub-trees). E.g. has permutations, but only unique ones.
Let be a multiset with elements where is an element and is the multiplicity of .
The number of unique permutations of is: