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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:14:59+00:00 2026-06-04T05:14:59+00:00

I have about 90000 IPv4 address ranges with data associated with each range e.g.

  • 0

I have about 90000 IPv4 address ranges with data associated with each range

e.g.

1.0.0.0 - 1.1.0.0 ->  "foo"
2.0.0.0 - 10.0.0.0 -> "bar"

Given an IP address, I need to retrieve the associated data. How can I do this efficiently?

I guess I can make things easier by converting the addresses to a single integer, but what data structure would be best to use to store this to enable fast searching?

Clarification – I’m searching with single IP, not a range (e.g. “192.168.0.1”)

Thanks

  • 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-04T05:15:01+00:00Added an answer on June 4, 2026 at 5:15 am

    Sort the ends of the non-overlapping intervals in a single array. Mark each end with a flag indicating if it is the beginning or the end of the interval, like this:

    1.0.0.0 1.1.0.0 2.0.0.0 10.0.0.0
     start   end     start    end
    

    Now run a binary search with the target address, say, 3.2.1.0. The insertion point falls on 2.0.0.0, which is marked as start. This means that 3.2.1.0 is one of the intervals.

    Now consider searching for 1.2.3.4. Its insertion point falls on 1.1.0.0, which is marked as end. Since 1.2.3.4 is not equal to the 1.1.0.0, we know that 1.2.3.4 is not one of the intervals.

    The cost of a search is Log(N), where N is the number of intervals.

    If you feel adventurous, consider implementing an interval tree. This is probably not worth it for non-overlapping intervals, though.

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

Sidebar

Related Questions

I have about 10 pictures, when :hover each picture there is an ajax.load that
I have about 20 classes for different messages and this number are growing. Each
I have about 10,000 products in the product table. I want to retrieve one
I have about 2200 different files in a few different folders, and I need
I have about 1 billion datasets that have a DatasetKey and each has between
I have about 5000 markers I need to render on Google Map. I'm currently
I have about 150 000 rows of data written to a database everyday. These
I have about 10million values that I need to put in some type of
I have about 100 sites built in a cms, each with its own database.
I have about 2000 subfolders in one folder, in each of these folders 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.