I was kind of aware of getting the average running time in a uniform distribution. Say for example we have 6 array elements.
| 1/6 | 1/6 | 1/6 | 1/6 | 1/6 | 1/6 |
Above is the array with the uniform probability distribution of a search element being positioned in every subscript in the array.
So getting the average running time in a uniform distribution will be like the solution below:
T(n) = (1/6)*1 + (1/6)*2 + (1/6)*3 + (1/6)*4 + (1/6)*5 + (1/6)*6
= (1/6) * ( 1 + 2 + 3 + 4 + 5 + 6 )
= 3.5
or when in express in n terms:
T(n) = (1/n) * ((n(n+1))/2)
= (n+1) / 2
= ϴ(n)
But what about the average-case number of key comparisons in sequential search under a geometric probability distribution?
Example:
Prob(target X is in the jth position) = 1/(2^(j+1))
where j = 0, 1, 2,3,4,5,6,...
| 1/(2^(0+1)) | 1/(2^(1+1)) | 1/(2^(2+1)) | 1/(2^(3+1)) | 1/(2^(4+1)) | 1/(2^(5+1)) |
Then
T(j) = ((1/2)* 1) + ((1/4)* 2) + ((1/8)* 3) + ((1/16)* 4) + ((1/32)* 5) + ((1/64)* 6)
= .5 + .25(2) + .125(3) + .0625(4) + .03125(5) + .015625(6)
= .5 + .5 + .375 + .25 + .15625 + .09375
= 1.875
I dont know how to express it in j terms:
T(j) = ?
What is the upperbound O(j)? lowerbound Ω(j)? tightbound ϴ(j)?
Any help or ideas , will be very much appreciated.
UPDATE:
I think that the formula for getting the run time is below:
T(j) = ((sum of geometric series) or (sum of geometric series / n)?)* (n((n+1))/2)
I just need first the formula for the sum of geometric series when each element in the series has the value 1/(2^(j+1)), where j = 0, 1, 2, ...up to n. Please help.
UPDATE:
I figured out that the formula for the sum og geometric series was 1- (1/2^n)
T(n) = (1-1/(2^n))/n * (n(n+1)/2)
= (n+1)/2 - (n+1)/(2^(n+1))
Now, my question is what is the Big Oh, Big Omega, Big Theta, little oh and little omega? Is it possible that an algorithm has no lower bound?