Questions tagged [multiset]

Anything related to multisets (a.k.a. bags), i.e. data structures that are generalizations of sets and in which an element can be present more than once. This tag applies to questions about multisets implementations, regardless of the specific programming language involved.

Anything related to multisets (a.k.a. bags), i.e. data structures that are generalizations of sets and in which an element can be present more than once. This tag applies to questions about multisets implementations, regardless of the specific programming language involved.

See Wikipedia page on multisets.

344 questions
7
votes
1 answer

Algorithm for finding multiset permutation given lexicographic index

I am trying to find an efficient algorithm to find permutation of a multiset, given an index. Ex: given {1, 3, 3}. All permutations in an ascending lexicographic order are {133, 313, 331}. These elements are indexed as {0, 1, 2}. Given index=2, the…
santa
  • 193
  • 10
7
votes
1 answer

Quick select with repeat values

Is it possible to perform searching kth elment in O(n) over multiset (values can repeat)? Because as far as I understand the idea of quick select I have to partition input using some pivot. Then I have 2 arrays, which I choose for recursive…
abc
  • 2,371
  • 3
  • 25
  • 36
7
votes
1 answer

What are the meaning of template parameters A, B of std::multiset respectively, and how does it work?

I have asked in another question about std::multiset, but now I see I need a decent understanding and cannot find any more complicated example in the internet. Can you explain to me, maybe exemplarize, how std::multiset works and what function…
berndh
  • 1,355
  • 4
  • 14
  • 19
6
votes
1 answer

Finite multisets as a HIT in Cubical Agda

In the standard library of Cubical Agda, there are finite multisets whose elegant definitions I reproduce below: {-# OPTIONS --cubical --safe #-} open import Cubical.Foundations.Prelude infixr 20 _∷_ data FMSet (A : Set) : Set where [] :…
Bob
  • 1,713
  • 10
  • 23
6
votes
5 answers

Finding (multiset) difference between two arrays

Given arrays (say row vectors) A and B, how do I find an array C such that merging B and C will give A? For example, given A = [2, 4, 6, 4, 3, 3, 1, 5, 5, 5]; B = [2, 3, 5, 5]; then C = multiset_diff(A, B) % Should be [4, 6, 4, 3, 1, 5] (the…
Sundar R
  • 13,776
  • 6
  • 49
  • 76
6
votes
3 answers

Is there something like mulitiSet in JavaScript?

I know that JavaScript now has sets, but I wonder if there is something to realize the function of multiSet, or if there is some framework that has the functions of multiset which I really need a lot. Or I have to code it by myself to do the…
hanzichi
  • 609
  • 2
  • 12
  • 22
6
votes
1 answer

Oracle Cast and MULTISET avaliable in POSTGRES

I have been working on a query to generate xml from the oracle database database where "column" is a type CREATE OR REPLACE TYPE "column" AS OBJECT ("coulmnname" VARCHAR2 (30), "datatype" VARCHAR2 (30)) and col_list_t is of…
SarthAk
  • 1,628
  • 3
  • 19
  • 24
6
votes
2 answers

How can I sort a Guava Multiset on entry value and count?

I have a Guava Multiset and would like to iterate independently through entries sorted on (a) element value and (b) element count. I have used Simplest way to iterate through a Multiset in the order of element frequency? as…
peter.murray.rust
  • 37,407
  • 44
  • 153
  • 217
6
votes
5 answers

c++ map/set iterator not dereferencable

I want to ask you for a hint, as I am a beginner and couldn't find any suitable answer in the internet. I am getting this error: debug assertion failed - map/set iterator not dereferencable at the line that looks like this: pointA =…
berndh
  • 1,355
  • 4
  • 14
  • 19
5
votes
3 answers

Python Counter Comparison as Bag-type

I need a bag/multiset-like data type in Python. I understand collections.Counter is often used for this purpose. But the comparison operators don't seem to work: In [1]: from collections import Counter In [2]: bag1 = Counter(a=1, b=2, c=3) In [3]:…
William Reed
  • 101
  • 4
5
votes
5 answers

Test if set is a subset, considering the number (multiplicity) of each element in the set

I know I can test if set1 is a subset of set2 with: {'a','b','c'} <= {'a','b','c','d','e'} # True But the following is also True: {'a','a','b','c'} <= {'a','b','c','d','e'} # True How do I have it consider the number of times an element in the set…
Joe Flip
  • 1,076
  • 4
  • 21
  • 37
4
votes
1 answer

what is the better feature do we have in multiset that is not in vector?

why we should use "multi set" (as we know "multi set" can keep repetitive key) why we shouldn't use vector instead ? is there any good feature in "multi set" that we don't have in vector ? (or other containers like vector) Do you know any special…
4
votes
2 answers

Intersections and Unions in Ruby for sets with repeated elements

How do we get intersections and unions in Ruby for sets that repeat elements. # given the sets a = ["A", "B", "B", "C", "D", "D"] b = ["B", "C", "D", "D", "D", "E"] # A union function that adds repetitions union(a, b) => ["A", "B", "B", "C", "D",…
Amin Shah Gilani
  • 8,675
  • 5
  • 37
  • 79
4
votes
4 answers

Best container for ordered elements

I am developing a time critical application and am looking for the best container to handle a collection of elements of the following type: class Element { int weight; Data data; }; Considering that the time critical steps of my…
shrike
  • 4,449
  • 2
  • 22
  • 38
4
votes
4 answers

Non-boolean "truth table" creation

I have the following problem: I need to create a table, which is combination of values coming from sets. The cardinality of the elements in the set is unknown, and may vary from set to set, the domain of the values is unknown, and may as well vary…
Andrea
  • 91
  • 8
1 2
3
22 23