Consider the following code, in which $\textsf{A}$ is an integer array of length $\textsf{n}$ indexed from $\textsf{0},$ and $\textsf{x}$ is an integer.
function foo (A, x, n) {
found = False ;
while (found != True) {
i = randInt (0, n) ;
if (A [i] == x)
found = True ;
}
}
return (i) ;
}
Here, $\textsf{randInt (0, n)}$ returns an integer picked uniformly at random from the range $\{ 0, 1, \dots, (n-1) \}.$
All integers present in array $\textsf{A}$ are distinct, and integer $\textsf{x}$ is present in array $\textsf{A}.$ Suppose we make the call $\textsf{foo (A, x, n)}.$ What is the expected number of times that the call $\textsf{randInt (0, n)}$ is made from within this call to $\textsf{foo (A, x, n)}?$