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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:02:33+00:00 2026-05-11T19:02:33+00:00

I have a list of linear ranges which represent one big range: X’ 100

  • 0

I have a list of linear ranges which represent one big range:

                                          X'
 100    200 300    400 500    600 700     |       900    (X)
|----------|----------|----------|--------+----------|
 0                                        |       100    (Y)
                                          Y'

X consists of the following ranges (even and round numbers are just examples for ease of comprehension, they could be anything, no proportions here at all):

  • From 100 to 200
  • From 300 to 400
  • From 500 to 600
  • From 700 to 900

On the flip side, Y has just one range:

  • From 0 to 100

Both X and Y are of the same length, just different units. Let’s say one is dollars and another is percents (or any other similarly unrelated units). So Y’0 == X’100 and Y’100 == X’900.

Given any point in Y, what is equivalent point in X and vise-versa, given a point in X – what is it in Y?

Is this a typical math problem? Does it have a name?

  • 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-11T19:02:33+00:00Added an answer on May 11, 2026 at 7:02 pm

    How many ranges do you have? Is it acceptable that the algorithm is O(number of ranges)?

    If so, below is the description of the algorithm. Let me explain it on your (original) example.

     100    200 300    400 500    600 700    800
    |----------|----------|----------|----------|
     0%                                     100%
    

    1) What you’re doing to do is to map the value X in range A (100-800) to the value Y in continous range B (0-399) (as the total number of elements in your range is 400). Then it’s easy to change position in B to percents, I will omit this part.

    2) Create a list of records, where each records represents one range mapping.

    struct RangeRecord {
      int start_in_a;
      int start_in_b;
    };
    

    In your case, you will get the following list:

    {100, 0}, {300, 100}, {500, 200}, {700, 300}
    

    3) When you need to map a number X from A to B, you iterate the list to find first record with start_in_a <= X.Then your value Y is

    Y = X + start_in_b - start_in_a;
    

    4) The algorithm is symmettric, you just iterate the list to find the first record with start_in_b <= Y, and then

    X = Y + start_in_a - start_in_b.
    

    Note 1. For error checking purposes, you might keep the range size in RangeRecord, as well.

    Note 2. If O(number of ranges) is not good enough, keep the records as a tree instead of a list. You will need O(log(number of ranges)) operations then,

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

Sidebar

Related Questions

I have 2 algorithms to do something (eg search a list) one has linear
I have 2 Linear layouts. One containing a list view and another with an
I have List I want to sort Desc by Priority, which is int and
I have list of files which contain particular patterns, but those files have been
I have List objects which are shown like this: www.mysite.com/lists/123 Where 123 is the
I have list in python which has following entries name-1 name-2 name-3 name-4 name-1
I have list of IPs: 238.51.208.96/28 238.51.209.180-199 238.51.209.100-109 238.51.213.2-254 ... How can I easily
I have completed implementing Operation of Linear Linked List using C , Now inorder
I have a linear list of zeros and ones and I need to match
I have a linear linked list that consists of nodes: class Node{ Object data;

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.