Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7075287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:09:33+00:00 2026-05-28T06:09:33+00:00

I’ll try to explain the problem in the math language. Assume I have a

  • 0

I’ll try to explain the problem in the math language.
Assume I have a set of items X = {x_1, x_2, ..., x_n}. Each item of X belongs to one of the sets S_1, S_2, ..., S_5. I consider all the subsets of X consisting of 5 items:
{x_i1, x_i2, ..., xi5} so x_i1 belongs to S_1, …, x_i5 belogns to S_5.
Some subsets are considered to be correct and some are considered to be not correct. Subset is considered to be correct if it does not contain conflicting items. I have a function f1 to determing if a pair of items conflict or not.
I also have a function f2 which can compare such correct subsets and say which subset is better (they might be equal as well).
I need to find the best not-conflicting subset(s).

Algo I used:
I built all the subsets, discarded not-correct subsets. Then I sorted correct subsets using f2 as a sorting function and took first best subset(s) (I used quick-sort algorithm). As far as there were a huge number of subsets this procedure took insufficient amount of time.

Is there a better approach in terms of time-consumption?

UPDATED
Let’s think of x_i as if it’s interval with integer endpoints. f1 returns true if 2 intervals do not intersect and false otherwise. f2 compares sum lengths of intervals in subsets.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T06:09:34+00:00Added an answer on May 28, 2026 at 6:09 am

    This problem is a variation of maximum weighted interval scheduling algorithm. The DP algorithm has polynomial complexity of O(N*log(N)) with O(N) space for the naive problem, and O(2^G * N * logn(N)) complexity with O(2^G * N) space for this variation problem, where G, N represent the total no of groups/subsets(5 here) & intervals respectively.

    If x_i doesn’t represent intervals, then the problem is in NP, which other solutions have proved.

    First let me explain the dynamic programming solution for maximum weighted interval scheduling, and then solve the variation problem.

    • We are given starting & ending points of the intervals. Let start(i), end(i), weight(i) be starting, ending point, interval length of the interval i respectively.
    • Sort the intervals based on increasing order of start point.
    • Let the sorted order of intervals be 1, 2, ... N.
    • Let next(i) represent the next interval that doesn’t overlap with interval i.
    • Lets define a subproblem S(i) to be the maximum weighted interval only considering jobs i, i+1, ... N.
    • S(1) is the solution, that considers all jobs from 1,2,... N and returns the maximum weighted interval.
    • Now lets define S(i) recursively.

    .

    S(i)  = weight(i)                             if(i==N) // last job
          = max(weight(i)+S(next(i)), S(i+1)
    

    Complexity of this solution is O(N*log(N) + N). N*log(N) for finding next(i) for all jobs, and N for solving the subproblems. Space is O(N) for saving subproblem solutions.

    Now, lets solve variation of this problem.

    • Lets collectively look at all the intervals in X. Each interval belongs to one of the sets S_1,… S_5.
    • Let start(i), end(i), weight(i), subset(i) be starting, ending point, interval length, subset of the interval i respectively.
    • Sort the intervals based on increasing order of start point.
    • Let the sorted order of intervals be 1, 2, ... N.
    • Let next(i) represent the next interval that doesn’t overlap with interval i.
    • Lets define a subproblem S(i, pending) to be the maximum weighted interval only considering jobs i, i+1, ... N and pending is a list of subsets from which we have to choose one interval each.
    • S(1, {S_1,...S_5}) is the solution, that considers all jobs 1,...N , chooses one interval for each of S_1,...S_5 and returns the maximum weighted interval.
    • Now lets define S(i) recursively as follows.

    .

    S(i, pending)  = 0                          if(pending==empty_set) // possible combination
                   = -inf                       if(i==N && pending!={group(i)}) // incorrect combination
                   = S(i+1, pending)            if(group(i) not element of pending)
                   = max(weight(i)+S(next(i), pending-group(i)),
                         S(i+1, pending)
    

    Note that I may have missed some base cases.

    Complexity of this algo is O(2^G * N * logn(N)) with O(2^G * N) space. 2^G * N represents the subproblem size.

    As an estimate, for small values of G<=10 and high values of N>=100000, this algo runs pretty quickly. For medium values of G>=20, N<=10000 should be low as well for this algo to converge. And for high values of G>=40, the algo doesn’t converge.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.