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?
1 Answer 1
If it is guaranteed that higher identifier means not lesser version then the fastest way is binary search.