  According to the hierarchical scenario, galaxies form via merging and
accretion of small objects. Using N-body simulations, we study the frequency of
merging events in the history of the halos. We find that at z<~2 the merging
rate of the overall halo population can be described by a simple power law
(1+z)^3. The main emphasis of the paper is on the effects of environment of
halos at the present epoch (z=0). We find that the halos located inside
clusters have formed earlier (dz \approx 1) than isolated halos of the same
mass. At low redshifts (z<1), the merger rate of cluster halos is 3 times lower
than that of isolated halos and 2 times lower than merger rate of halos that
end up in groups by z=0. At higher redshifts (z~1-4), progenitors of cluster
and group halos have 3--5 times higher merger rates than isolated halos. We
briefly discuss implications of our results for galaxy evolution in different
environments.
