0

I've got an API endpoint which looks like this: http://foo.bar/rest-method/{identifier}.
This API returns an object that looks like that:

{
    name: "Example",
    version: "1.0.5.3937"
}

Now I know that the entry with the identifier 2923711253 has got version 1.0.5.3937 while the entry with the identifier 2923823024 has 1.0.6.1334.

I want to find out which identifier is the last one using version 1.0.5.3937 and which is the first one using 1.0.6.1334. I call it 'the breaking point'.

Of course I could write a loop which simply checks all the identifiers which are between the two definied one's, but that seems very inefficient to me.

What algorithm should be used here?

3

If it is guaranteed that higher identifier means not lesser version then the fastest way is binary search.

  • indeed, git or hg bisect – jk. Nov 9 '16 at 12:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.