Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Last Updated: Mar 27, 2024

# Multisets

Leveraging ChatGPT - GenAI as a Microsoft Data Expert
Speaker
Prerita Agarwal
Data Specialist @
23 Jul, 2024 @ 01:30 PM

## Introduction

As we have already gone through Set theory in the previous blogs, Sets are a collection of well-defined elements, objects, or numbers. The elements of a set can be in any order, but here comes the crucial point, no element can be repeated in a set, i.e., the elements should be unique. In this blog, we are going to learn multisets. A multiset is nothing but a generalisation from the set concept, where any element can occur a finite number of times, irrespective of its order, i.e., repetition of an element is allowed.

## Multisets

multiset is a set-like, unordered collection of elements where the repetition of elements matters. The number of occurrences of an element in the multiset is called multiplicity. A multiset is usually denoted by writing its elements, separated by commas, between curly braces.

For example, {m, m, n, o, n}. It can also be denoted by writing the elements and their multiplicities as colon-separated pairs: for example, {m:2,n:2,o:1}, which avoids confusing it with a standard set.

Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job
Bootcamp

## Terminology

1.If m occurs in a multiset M at least n times, we can write it as âˆˆM. For example, a âˆˆ {a, b, b, a, b} and b âˆˆ{a, b, b, a, b}.

2. Multiplicity: The number of times an element occurs in a multiset is called its multiplicity. The multiplicity of an element mâˆˆM is denoted by Î½M(m).

3.If multiplicities of two sets are the same, they are said to be equivalent multisets.

4.Multiset X is a multisubset of Y if multiplicities of all the elements in X are less than or equal to the multiplicities of those elements in Y. It is denoted by X âŠ† Y.

5.Multiset X is said to be a proper multisubset of Y if X is a multisubset of Y and X â‰  Y. It is denoted by X âŠ‚ Y.

6.The cardinality of a multiset is the number of elements in it, including every element's multiplicity.

7.Powerset of a multiset P(X) is a set having all multisubsets of X.

8.Universal multiset (U) is a multiset containing all relevant elements with relevant multiplicities.

## Operations on Multisets

1. Union of multisets: Union of two multisets X and Y is a multiset where the multiplicity of an element is equal to the maximum multiplicity of an element in X and Y and is denoted by X âˆª Y.

2. Intersection of multisets: The intersection of two multisets X and Y is a multiset where the multiplicity of an element is equal to the minimum multiplicity of an element in X and Y . It is denoted by X âˆ© Y.

3. Sum of multisets: The sum of two multisets, X and Y, is a multiset such that the multiplicity of an element is equal to the sum of the multiplicity of an element in X and Y.

4. Difference of multisets: The difference of two multisets Xâˆ’Y is a multiset where the multiplicity of each element is max(Î½Aâ€‹âˆ’Î½B,0).

## FAQs

1. How do you denote a multiset?
A multiset is usually denoted by writing its elements, separated by commas, between curly braces. For example, {m, m, n, o, n}. It can also be denoted by writing the elements and their multiplicities as colon-separated pairs: for example, {m:2,n:2,o:1}, which avoids confusing it with a standard set.

2. What is the difference between a set and multiset?
A set is a collection of well-defined elements, and every element should be unique. The difference between a set and multiset is that multiset allows repetition of elements while set does not.

3. Define multiplicity of a multiset.
The number of times an element occurs in a multiset is called its multiplicity. Multiplicity of an element m âˆˆ M is denoted by Î½M(m).

## Key Takeaways

In this article, we have extensively discussed Introduction to multisets, its mathematical definition, associated terminologies and operations on multisets. We hope that this blog has helped you enhance your knowledge, and if you wish to learn more, check out our playlist Basic Mathematics. You can also go through our Coding Ninjas Blog site and visit our Library.
Check out this problem - Redundant Braces

Recommended Readings:

Do upvote our blog to help other ninjas grow.

Happy Learning!

Topics covered
1.
Introduction
2.
Multisets
3.
Terminology
4.
Operations on Multisets
5.
FAQs
6.
Key Takeaways