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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T01:27:19+00:00 2026-05-11T01:27:19+00:00

I need an idea for an efficient index/search algorithm, and/or data structure, for determining

  • 0

I need an idea for an efficient index/search algorithm, and/or data structure, for determining whether a time-interval overlaps zero or more time-intervals in a list, keeping in mind that a complete overlap is a special case of partial overlap . So far I’ve not not come up with anything fast or elegant…

Consider a collection of intervals with each interval having 2 dates – start, and end.

Intervals can be large or small, they can overlap each other partially, or not at all. In Java notation, something like this:

interface Period  {   long getStart(); // millis since the epoch   long getEnd();   boolean intersects(Period p); // trivial intersection check with another period }  Collection<Period> c = new ArrayList<Period>(); // assume a lot of elements 

The goal is to efficiently find all intervals which partially intersect a newly-arrived input interval. For c as an ArrayList this could look like…

Collection<Period> getIntersectingPeriods(Period p) {   // how to implement this without full iteration?   Collection<Period> result = new ArrayList<Period>();   for (Period element : c)     if (element.intersects(p))       result.add(element);   return result; } 

Iterating through the entire list linearly requires too many compares to meet my performance goals. Instead of ArrayList, something better is needed to direct the search, and minimize the number of comparisons.

My best solution so far involves maintaining two sorted lists internally and conducting 4 binary searches and some list iteration for every request. Any better ideas?


Editor’s Note: Time-intervals are a specific case employing linear segments along a single axis, be that X, or in this case, T (for time).

  • 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. 2026-05-11T01:27:19+00:00Added an answer on May 11, 2026 at 1:27 am

    Interval trees will do:

    In computer science, an interval tree is a tree data structure to hold intervals. Specifically, it allows one to efficiently find all intervals that overlap with any given interval or point. It is often used for windowing queries, for instance, to find all roads on a computerized map inside a rectangular viewport, or to find all visible elements inside a three-dimensional scene. A similar data structure is the segment tree…

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

Sidebar

Ask A Question

Stats

  • Questions 89k
  • Answers 89k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Well, for two reasons really: Because of portability, since some… May 11, 2026 at 5:53 pm
  • Editorial Team
    Editorial Team added an answer The problem is you're using "expires:" with a colon. Needs… May 11, 2026 at 5:53 pm
  • Editorial Team
    Editorial Team added an answer One way to control the instantiation of static objects is… May 11, 2026 at 5:53 pm

Related Questions

edit: many thanks for all the answers. Here are the results after applying the
I want to ask how other programmers are producing Dynamic SQL strings for execution
I work on a web game , I use asp.net mvc, linqtosql. I have
I am attempting to build a .PLY parser to load 3d models stored as

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.