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

  • Context: Graduate 
  • Thread starter Thread starter Moni
  • Start date Start date
  • Tags Tags
    Elements Sums
Click For Summary

Discussion Overview

The discussion revolves around generating subsets of a multiset in ascending order based on the sums of their elements. Participants explore algorithmic approaches to efficiently produce these subsets without generating all possible combinations first, particularly in the context of computational efficiency.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant proposes the need for an algorithm that generates combinations of a multiset in an order where their sums are in increasing order.
  • Another participant questions how to distinguish between identical elements in the multiset when using set notation.
  • A participant suggests that while sorting algorithms could be used, generating all combinations first may be inefficient, especially when a significant portion of desired results can be found early in the generation process.
  • Another reply argues that sorting after generation is a feasible approach, but emphasizes that generation itself is an unavoidable cost that must be addressed.

Areas of Agreement / Disagreement

Participants express differing views on the efficiency of generating subsets versus sorting them afterward. There is no consensus on the best approach to take, and the discussion remains unresolved regarding the optimal algorithm for the task.

Contextual Notes

Participants highlight the computational expense of generating all subsets and the potential for early results, but do not resolve the implications of these factors on the algorithm design.

Moni
Messages
178
Reaction score
1
TL;DR
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.
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 20 ·
Replies
20
Views
2K
  • · Replies 11 ·
Replies
11
Views
4K
  • · Replies 16 ·
Replies
16
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 57 ·
2
Replies
57
Views
7K