findHole(S)
{
k = 0;
previous_k = 0;
current_f = f(k, S);
if (current_f == 1) return (S);
previous_f = 0;
//While the probability of finding a hole increases,
//we increase k and verify if the vertex at k steps is a hole
while (current_f >= previous_f)
{
previous_f = current_f;
previous_k = k;
//As closer to probability 1 we are, as smaller steps we make
k = (1 - current_f) * MAX_STEP_SIZE;
current_f = f(k, S);
if (current_f == 1) return (S);
}
//If we overshot our hole and the probability of finding
//a hole at k steps distance has started to decrease, we
//perform a binary search within the boundaries of the interval
//[previous_k, k], with probabilities in [previous_f, current_f],
//having a guarantee that our hole is within this interval
return binSearch(previous_k, k, S);
}