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

  • Home
  • SEARCH
  • 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 8036081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:30:05+00:00 2026-06-05T02:30:05+00:00

Suppose we are given a set of closed intervals where each interval is in

  • 0

Suppose we are given a set of closed intervals where each interval is in the form of [l,r]. If we want to select two intervals from this set such that the size of their intersection times the size of their union is the maximum. Can we provide a nontrivial algorithm to solve this problem?

For example, if we have four intervals, [1,6], [4,8], [2,7], [3,5]. The optimum solution is to select [1,6] and [2,7]. The answer is (7-1) * (6-2) = 24.

Actually the original problem requires us to select (N>=2) number of intervals but I think we can prove that the optimal solution only consists of two intervals:

If the optimum solution has three or more intervals:

[                     ]
            [               ]
                   [                          ]

We can see that the weight won’t decrease if we delete the middle interval.

  • 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-06-05T02:30:06+00:00Added an answer on June 5, 2026 at 2:30 am

    Given a set of N > 2 overlapping intervals which supposedly maximises union times intersection, set aside an interval containing the leftmost point in the union and an interval containing the rightmost point in the union. Since N > 2 you have at least one other interval left. If you remove this interval from the set, you do not decrease the size of the union of intervals, because you set aside intervals to cover the leftmost and rightmost points. You can only increase the size of the intersection by removing an interval. So by removing this interval you can only increase the product you are trying to maximise, so the best solution can indeed be found at N = 2.

    Sort the set of endpoints of intervals and go through it in increasing order. In case of ties, consider leftmost points before rightmost points. Keep track of a set of intervals, adding an interval to the set when you see its leftmost point, and removing an interval from the set when you see its rightmost point.

    For any two overlapping intervals, there will be a point when one of them is already present and you are just about to add the other one. So if, just before you add an interval to the set, you compare it with all other intervals already in the set, you can compare all pairs of overlapping intervals. You can therefore compute the product of union and intersection between the interval about to be added and all other intervals in the set and keep track of the largest one seen.

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

Sidebar

Related Questions

Let E be a given directed edge set. Suppose it is known that the
Suppose I have a given ObjectDataSource, this objectdatasource SelectMethod property is set to GetProjectsByUsername
Suppose that you're given an array A of n distinct elements drawn from some
I have this question in my text book: Suppose that we have a set
Suppose I have a database like this: This is set up to give role-wise
Suppose that my Haskell function is given an input, which is supposed to be
Suppose I have a set of data, given the data and the relation schemas
Suppose I am using this data set of movie ratings: http://www.grouplens.org/node/73 It contains ratings
I'm trying to fetch objects from core data that are not in a given
Given some jQuery object set, and also a subset of that set, is there

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.