0

Imagine that I've got a big $N \times N$ boolean matrix (all entries are $0$ or $1$). At the beginning, the matrix is full of zeros.

Then, I execute the following algorithm

Matrix M empty of type N x N
while (there is a 0 in M) {
    Position pos;
    do {
        pos = random position in M
    } while (pos is 1);
    // Here pos is 0
    mark pos as 1;
}

I want the cost of the previous algorithm (suppose that "there is a $0$ in $M$" has no cost, and that "random position in M" has constant, i.e. $\Theta(1)$, cost).

My intuition says that it is $\Theta(\cdot)$ of $$ 1 + \textrm{Geom}\left(\frac{N^2 -1}{N^2}\right) + \textrm{Geom}\left(\frac{N^2 -2}{N^2}\right) + \cdots + \textrm{Geom}\left(\frac{1}{N^2}\right) $$

JnxF
  • 1,277

0 Answers0