How to get the expected running time of an algorithm I have an algorithm which, basically given an array of $n$ numbers, checks if there is any repeated numbers in the array, and returns true if there is and false otherwise.

It uses a direct access table (hashing function $h(x)=x$), which makes the running time linear. So it creates a new array, initializes all values to false, then iterates through the given array, and since each value is an index to the hash table, it accesses that array location and changes it to $1$. If it is already a $1$, then you know that it is a repeated number.

But when getting the expected running time, you need to first define a probability space. This is the part I am confused about. How can you define a probability of a number being repeated in A, if you are just given an array with arbitrary numbers?
Usually you assume uniform distribution on inputs which share a certain parameter. 
You could assume uniform distribution on e.g.


All inputs of length $n$, e.g. if your input looks like $w_1\#\dots\#w_k$, where $w_i\in\{0,1\}^*$, $n=k-1+\sum_{i=1}^k|w_i|$.
All multisets (bags) of $n$ integers up to $k$
All $n$-tuples of integers integers up to $k$ (different,since e.g. $\{1,2\}_b$ corresponds to $(1,2)$ and $(2,1)$ and $\{1,1\}_b$ only to $(1,1)$)


You can combine this with an assumption about the distribution of the parameter, say the size $n\sim \mathrm{Geo}(0.5)$. However, this is unusual, most would consider the limit of probabilities as your parameter $n\rightarrow\infty$ instead.


If you choose 3, the probability of no repeated numbers can be calculated this way:
There are different $\binom{k}{n}$ sets of size $n$ and each set corresponds to $n!$ $n$-tuples. There is a total number of $k^n$ $n$-tuples, so
$$P(\text{no repeated number})=\frac{\binom{k}{n}\cdot n!}{k^n}$$