I've read some posts about counting the number of assignment inside code of finding the maximum value in array like this:
FindMax(L):
n = len(L)
max = L[1]
for i = 2..n:
if (max < L[i])
max = L[i] (**)
return max
According to this post and post, it's about the array that elements are strictly distinguish. So if the array contains values may be duplicated (for example, elements are integer in range [1, m], m = 3, with any length of array), how could we calculate the number of (**) will be executed in average case?