A Ascending Order of the Sums of the Elements of the Sub(multi)set of MultiSet

  • A
  • Thread starter Thread starter Moni
  • Start date Start date
  • Tags Tags
    Elements Sums
Moni
Messages
178
Reaction score
1
TL;DR Summary
Generating Subsets of a Multiset in Ascending Order of the Sums of the Elements of the Sub(multi)set
Summary: Generating Subsets of a Multiset in Ascending Order of the Sums of the Elements of the Sub(multi)set

I am trying to come up with an algorithm where you can generate combination from a set in a order such that their sums are in increasing order. This set has to be a multiset i.e. repetition allowed.
For example you have a set S = {1,2,2,3,4,5,5}
So, rather than generating all the combinations based on number of items (say start with 1 and 2 items and finally all 7) I want to figure them out in this order:
{1}, {2}, {2}, {1,2}, {1,2}, {3}, {1,3}, {2,2}, {4}.....{1,2,2,3,4,5,5}
Why this order: Well taking sum of these subsets we can see:
{1}, {2}, {2}, {3}, {3}, {3}, {4}, {4}, {4}.....{22}
Do you know any algorithm which can do it efficiently?
 
Physics news on Phys.org
I'm not sure how you arrived at the copies of those singlets, i.e. how you distinguish the elements in ##S## if they have the same name? That's nothing the ##\{\,\,\}## notation allows.

Anyway, why don't you use one of the usual sort algorithms?
 
Hi, yes sorting algorithms can be used, but then you need to generate all of the combinations and then sort it. But the project I am working on, there the result might be available in the first 25% of the numbers (80% of the time) that means if you have say, 100 submultisets (powerset) and if you can generate that sequence (their sums ascending ordering) then you might get the desired combination (submultiset) within first 25 generated ones. Generating all of them in those cases is computationally expensive!
 
You can sort them right after generation, which is cheap. That leaves us with the question,whether generation has to be done or not. However, they occur in your final list, so they will have to be produced at some stage. Hence generation is the only and unavoidable cost.
 
Hi all, I've been a roulette player for more than 10 years (although I took time off here and there) and it's only now that I'm trying to understand the physics of the game. Basically my strategy in roulette is to divide the wheel roughly into two halves (let's call them A and B). My theory is that in roulette there will invariably be variance. In other words, if A comes up 5 times in a row, B will be due to come up soon. However I have been proven wrong many times, and I have seen some...
Thread 'Detail of Diagonalization Lemma'
The following is more or less taken from page 6 of C. Smorynski's "Self-Reference and Modal Logic". (Springer, 1985) (I couldn't get raised brackets to indicate codification (Gödel numbering), so I use a box. The overline is assigning a name. The detail I would like clarification on is in the second step in the last line, where we have an m-overlined, and we substitute the expression for m. Are we saying that the name of a coded term is the same as the coded term? Thanks in advance.

Similar threads

Back
Top