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 8227675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:12:16+00:00 2026-06-07T16:12:16+00:00

I have a data set of events (start date, end date, location). These events

  • 0

I have a data set of events (start date, end date, location). These events move in the country and I need to figure out which event should go where after it ends.

Exemple:

  1. [1/7, 6/7, Toronto] (Starts the 1st of July, ends the 6th of July)
  2. [2/7, 4/7, Montreal]
  3. [4/7, 11/7, Ottawa]
  4. [17/7, 22/7, Vancouver]

..etc (Data set will be around 100 entries, so performance is not really an issue)

In this exemple, Event 1 could move and do Event 4, since it ends on the 6th of July and Event 4 starts on the 17th. (Assuming transit in the same day)

All Events that couldn’t find a suitable match will be stored in a report for someone to match manually.

This optimization code will be done in javascript.

My first thought was to have 2 arrays, with the same data. First array sorted by Start Date, 2nd array sorted by End Date. Then go through the list of End Dates and try to find an appropriate Start Date for it, then remove these entries from the array and continue like that until no more matching is possible.

Anybody has a better idea on how to approach this problem ? If you need more details let me know!

  • 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-07T16:12:18+00:00Added an answer on June 7, 2026 at 4:12 pm

    Your question isn’t very clear. If I understand correctly, your goal is to choose a subset of events such that your selection maximizes the number of events (and there are not overlapping events). If so, your problem can be seen as an Activity Selection Problem. There is a simple greedy algorithm to solve that.

    Let

    event[1..n] the n events
    start[i] the start time of the event number i
    finish[i] the finish time of the event number i
    

    and assume that you already sorted the events by end time.

    The following greedy algorithm will find the largest subset S of non overlapping events:
    (note that lse is the Last Selected Event)

    S = {event[1]}
    lse = 1
    
    foreach event[i] do:
         if start[i] > finish[lse]:
             S = S + {event[i]}
             lse = i
    
    return S
    

    Basically:

    1. you sort the events by end time
    2. you select the 1st event
    3. you loop on the events, greedily choosing the 1st one that doesn’t overlap with the last one you choose
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a data set which consists of an ID and a matrix (n
I have a massive (~10 9 ) set of events characterized by a start
I have a data validation class that checks whether the start date of a
I have a data set comprised of 5 minute price observations (not an xts
I have a data set that resembles this: id product_id size color price created_date
I have a data set with over 50,000 geocoded points (lat-long). Each point has
I have a data set that is around 700 rows with eight columns of
I have a data set that that I would like to call in a
I have a data set of item difficulties that correspond to items on a
how can I have a data set of only time intervals (no dates) in

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.