Yet Another Blog

Posts Tagged ‘Probability

Analyzing a random search in a tree

with 2 comments

Problem:
This is a 500-points problem from TC SRM440 Div1. It can be summarized as follows:

We are given a matrix. Some cells are marked closed and others are marked open. We can only move from one open cell to an adjacent open cell. The matrix is defined such that there is one and only one way from one open cell to another.

Our target is to reach a specific open cell, let’s call it the target cell. Our starting point is uniformly random (can be the target cell itself). Moving from one cell to another takes one second. Our motion is also uniformly random; that is, whenever we are in an open cell, the probability to move from that cell to any of the adjacent open cells is the same for all adjacent open cells (but we must move, we can’t stand still).

It is required to calculate the expected time to reach the target cell.

Solution:
Since the starting cell is uniformly random, we will calculate the expected time to reach the target cell for each possible starting cell; then the required overall expected time is just the average of all those expected times.

Let the open cells be c_0, c_1, c_2, ... , c_n where c_0 is the target cell. For the special case where c_0 is the starting cell, the expected time equals 0. We need to calculate the expected time for the rest.

For any cell c_i, where 0<i\le n, let the expected time to reach c_0 be E_i. If the degree (the number of adjacent cells) of c_i is d_i then the probability of going to any of the adjacent cells is \frac{1}{d_i}. If we are in cell c_i, and we chose to go to the adjacent cell c_j then the expected time to reach c_0 will be one second (for moving from c_i to c_j) plus E_j (the expected time to reach c_0 from c_j). We end up with the following formula for E_i:

E_i = \displaystyle\sum_{j:\ c_j\ adjacent\ to\ c_i} {\displaystyle\frac{1}{d_i} (1+E_j)} = 1 + \displaystyle\frac{1}{d_i} \displaystyle\sum_{j:\ c_j\ adjacent\ to\ c_i} E_j

This is a system of linear equations that can be solved with any appropriate method, for example Gauss-Jordan elimination.

Comments:
The interesting thing with this problem is that it is asking for an algorithm to analyze the performance of a heuristic! We can think of this matrix as an undirected graph, where open cells of the matrix are vertices of the graph, and adjacent open cells correspond to adjacent vertices. Since there is one and only one way between any two open cells then it is actually a tree, and the algorithm is just analyzing the performance of a random search in a tree.

Written by Hatem Abdelghani

May 13, 2009 at 10:59 pm

Follow

Get every new post delivered to your Inbox.