At first, I thought it depends on the waveform of the sound ... sine wave,
square wave, sawtooth wave, complex wave, etc. But the magnitude of
the compression must be equal to the magnitude of the rarefaction. It
it weren't, then air molecules would creep along the wave in the direction
of one or the other, and the wave would carry matter as well as energy ...
and we know that waves don't do that.
Sound travels fastest in ice because energy is easier to transfer when the molecules are close together. Sound travels slowest in steam because the sound has to move around the gas molecules that are far apart.