Probability of linear search with repeated elements.

132 Views Asked by At

I am trying to find the probability that a linear search on an array of size n takes j comparisons. We are looking for the element x and there are k x's in the array where 0 < k < n. I tried looking at this as a conditional probability problem but I ended with an overly complicated factorial that I can't simplify and now I am stuck any help is appreciated.