Apple, Microsoft and other technology leaders have competed for the top market valuation. Their relative positions changed as share prices rose and fell.

The race shows how investor expectations can shift even among the world’s biggest companies.