Multiset (also called Bag) is a data structure similar to a set but allows duplicate elements. Each element stores a count representing how many times it appears.
Key Characteristics:
Applications: Frequency counting, word analysis, inventory management, and anagram checking.
Strengths:
Limitations:
| Operation | Average Time | Worst Time | Space |
|---|---|---|---|
| Add Element | O(1) | O(n) | O(1) |
| Remove Element | O(1) | O(n) | O(1) |
| Search Element | O(1) | O(n) | O(1) |
| Decrease Count | O(1) | O(n) | O(1) |
| Space | - | - | O(n) |
n = number of unique elements