title: What is the best time and space complexity achievable with finding a number in various number ranges?
body: <p>I want to ask a user a 2 number range to generate a third one. <em>(This is done to set a custom selling price following a market trend.)</em></p>
  <p>For example, between 1 and 2, generated number is 3. Between 2 and 3, it will be 4.5 <em>(this number is fixed by the user and we must store it)</em>.</p>
  <p>Then, when I will be processing some data and will just have the market price number, I will have to know in which number range it is &quot;located&quot; and find the according generated number.</p>
  <p>I thought about storing 3 datas : startingValue, endingValue and userValue. But this means that I have to retrieve all data and browse each number ranger each time, which leads to N in space and time complexity.</p>
  <p>I somehow feel this could be done in constant time.</p>
  <p>Would you have any idea ? Or am I doing it wrong ?</p>