Artificial intelligent assistant

Combinatoric task about flock of sheep Flock of sheep is walking on the path in one direction. There are 30 sheeps. Initially they all have different random speeds. The main feature is that in the process of walking, if a sheep at a faster speed bumps on a sheep which has a slower speed, then the faster sheep starts moving with the speed of this slower sheep. Obviously, through a sufficiently large amount of time this flock will be divided into groups which have a constant speed. The task is to find the average number of groups. Edit: Let's consider uniform distribution of speeds: each sheep given a uniform random speed in (0,1) independently. PS. Can you look at my answer and check my logic?

Providing that all orders of sheep speeds are equally likely and no pair of sheep have the same speed, the $n$th sheep (counting from the front) is the slowest of its group if and only if all $n-1$ sheep in front of it are all faster than it is, which has probability $\dfrac{1}{n}$

Each group has precisely one slowest sheep, so with $30$ sheep the expected number of groups is $$\displaystyle \sum_{n=1}^{30} \dfrac1n \approx 3.995$$

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 35251f75560de943e1c4eb7515aeb8ee