Let are the random variables.

Let

Plan of Action

- Find CDF for X
- Find PDF for X using CDF
- Compute

Note that

Thus

so

Alternative way :

For non-negative random variables, some times it is easy to calculate expected value of random variable using following formula :

Since in our case cannot take value greater than 1

]]>

Proof :

]]>

Assuming that next I/O request resides in any cylinder with equal probability, what is the distance travelled by head, on average, between successive seeks on disk with cylinders.

D = random variable denoting the distance travelled between successive seeks

]]>

How many pieces of thread will be needed in general ? i.e; given number of pins N and clockwise gap G, Express the number of Threads needed T, as a function of N & G.

Source : ” Thinking Mathematically ” by John Mason et.al

PS: This problem is related to “rotation of array” problem where you are asked to rotate the array by a given amount using only O(1) extra space. For example, rotating array containing 3, 5, 9, 14, 1, 2, 11 by 3 positions will yield 14, 1, 2, 11, 3, 5, 9.

PPS : I highly recommend “Thinking Mathematically” for kids, it helps to develop good practices which aid in solving problems.

]]>

Let denote the desired probability. Then , and for , By conditioning on coin’s outcome, we can see that

Using above recurrence we get . Now it is easy to guess that . It is easy to verify this guess using Mathematical Induction.

Now, let us see alternative way to derive the same result using Generating Functions.

If is a discrete random variable taking values on some subset of the non-negative integers,{0,1,….,n}, then the probability-generating function of X is defined as :

where symbol denotes the Expectation of Random Variable.

If is a sequence of independent ( not necessarily identically distributed ) random variables, and , then the probability-generating function of is given by

.

The last equality follows from the fact that the expectation of product of independent random variables is equal to the product of expectation of individual random variables.

Let the probability of heads on be donted by . So . Let

Let denote the indicator random variable, which takes on value 1 if falls on heads, takes value 0 otherwise

P.G.F of is

Let denote the number of heads in the *n* coin tosses. So

P.G.F of is

The probability of getting exactly *m* heads is equal to the coefficient of in the generating fucntion, that is .

Since the coin tosses are independent,

Notice that

and

The required probability is

Hence

It is easy to interpret the result of substituting 1 for *z *in terms of probability : it is the probability of Sample Space , which is 1. The result of substituting -1 for *z,* is the Difference between probability of getting Even number of heads and probability of getting Odd number of heads ( Generating functions actually helped in calculating this difference easily ). The difference is equal to . In retrospect, we can see why this is so. If we expand this product we see that each +ve term in the expansion correspond to the probability of some sample point which has even number of heads in it, and each -ve term in the expansion correspond to probability of some sample point which has Odd number of heads in it. Hence the sum of +ve terms is equal to probability of getting Even number of heads, and the sum of -ve terms is equal to probability of getting Odd number of heads.

]]>

Now, Given a list of *n *strings find if they can be chained together . Note that this is YES/NO question, i.e; you need not come up with the actual order of chaining.

Try to come up with *O(n)* solution.

]]>

]]>

Let be a random variable which denotes the size of the subtree of a randomly chosen vertex in recursive tree of size *m*. Show that

1) For , P( = *m *) =

and, for * *,

2) P( = *k ** *) = , if .

PS:: This result is proved in following paper : ” Breakage and Restoration in Recursive Trees ” . I am looking for different approach. Any Ideas ??

]]>