Let's say an individual invests a sum of money on an index, say, through Vanguard (e.g. VFIAX or VTSAX):
How does the allocation of this investment get distributed across shares of the companies in the index?
E.g. is it, evenly across all shares of the index? or does this depend on the index?
As companies enter and leave the index, how does that investment get re-allocated? Since I understand an index fund is passively managed, I assume the re-distribution happens automatically, but how / when?
For example if the sale of shares of company leaving the index results in $X, how does $X get redistributed across the new companies in the index?)
Are the answers to the above different for ETFs vs index funds?