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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:36:48+00:00 2026-05-11T22:36:48+00:00

You are given a list of distances between various points on a single line.

  • 0

You are given a list of distances between various points on a single line.

For example:

  • 100 between a and b
  • 20 between c and b
  • 90 between c and d
  • 170 between a and d

Return the sorted sequence of points as they appear on the line with distances between them:

For example the above input yields:
a<—-80—–> c <—-20——> b <—-70—–> d or the reverse sequence(doesn’t matter)

What is this problem called? I would like to research it.

If anybody knows, also, what are some of the possible asymptotic runtimes achieved for this?

  • 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-11T22:36:49+00:00Added an answer on May 11, 2026 at 10:36 pm

    not sure it has a name; more formally stated, it would be:

    |a-b| = 100
    |c-b| = 20
    |c-d| = 90
    |a-d| = 170
    

    where |x| stands for the absolute value of x

    As far as the generalized system goes, if you have N equations of this type with k unknowns, you have N choices of sign. Without loss of generality (because any solution yields a second solution with reversed ordering) you can choose a sign for the first equation, and a particular value for one of the unknowns (since the whole thing can slide left and right in position). Then you have 2N-1 possibilities for the remaining equations, and all you have to do is go through them to see which ones, if any, have solutions. Because the coefficients are all +/- 1 and each equation has 2 unknowns, you just go through them one by one:

    Step 1: Without loss of generality, 
      choose a sign for one equation
      and pick a value for one unknown:
    a-b = 100, a = 0
    
    Step 2: Choose signs for the remaining absolute values.
    a = 0
    a-b = 100
    c-b = 20
    c-d = 90
    a-d = 170
    
    Step 3: go through them one by one to solve / verify there aren't conflicts 
    (time = N steps).
    0-b = 100  =>  b = -100
    c-b = 20   =>  c = -80
    c-d = 90   =>  d = -170
    a-d = 170  =>  OK        => (0,-100,-80,-170) is a solution
    
    Step 4: if this doesn't work, go back through the possible choices of sign 
    and try again, starting at step 2.
    
    Full set of solutions is (0,-100,-80,-170) 
    and its negation (0,100,80,170) and any number x<sub>0</sub> added to all terms.
    

    So an upper bound for the runtime is O(N * 2N-1) ≡ O(N * 2N).

    I suppose there could be a shortcut but no obvious one comes to mind.

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

Sidebar

Related Questions

Given a list of potential ID's is there a quick way using a single
Given a list of numbers, how does one find differences between every ( i
Given a list of points on a 2D plane how could one place N
Closest pair of points problem is well-known in computational geometry:given a list of points
Given multiple (x,y) ordered pairs, I want to compare distances between each one of
Given an R list, I wish to find the index of a given list
The original code was somehow complex, i simplify it as: Given: list of class
Given a list a containing vectors of unequal length and a vector b containing
Given a List such as List(1, 2, 3, 4, 5, 6, 7) what is
Given a list like this: num = [1, 2, 3, 4, 5] There are

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.