0
$\begingroup$

I have an array of time variables t(1), t(2), ..., t(n). and corresponding variables v(1), v(2), ..., v(n). Given a time tx, I would like to efficiently find between which interval (t(i), t(i+1)] does the number lie. Correspondingly, the variable vx needs to be interpolated which can be done easily afterwards.

P.S: The time t(i=1) is initialized with t1 and is always increasing and greater than zero.

$\endgroup$
2
  • 3
    $\begingroup$ Do you know binary search? $\endgroup$
    – Tassle
    Aug 23, 2019 at 19:33
  • $\begingroup$ @Tassle: Thanks, I am vaguely aware of it and will look into. After posting question, I realize that there is some predictability meaning that the search interval will keep shrinking if I store the index i, since time is always increasing. $\endgroup$
    – SKPS
    Aug 23, 2019 at 19:38

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.