Skip to content

Instantly share code, notes, and snippets.

@jszuppe
Created November 1, 2015 17:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jszuppe/13e40ae7007c6b2901f6 to your computer and use it in GitHub Desktop.
Save jszuppe/13e40ae7007c6b2901f6 to your computer and use it in GitHub Desktop.
uint x = 0;
while(l_idx < r_idx && x < 32)
{
int mid_idx = (l_idx + r_idx) / 2;
int mid_value = input[mid_idx];
if(x > 11)
printf("gid: %d, mine: %d, l_dix: %d, r_idx: %d, mid_idx: %d, mid_value: %d, x: %d\n", gid, mine_value, l_idx, r_idx, mid_idx, mid_value, x);
if(mid_value > mine_value) // 1st division
{
r_idx = mid_idx;
}
else if (mid_value < mine_value) // 2nd division
{
l_idx = mid_value + 1;
}
else
{
l_idx = mid_idx;
r_idx = mid_idx;
}
x++;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment