Longitudinal Wave
When a longitudinal wave propagates, it compresses and rarifies the medium. The particles in the medium move back and forth along the direction of propagation of the wave. As a result, there are regions with high and low pressures. A few examples of longitudinal waves are the sound wave, ultrasound wave, and seismic P-wave. Waves traveling through the bulk of fluid are longitudinal waves.
Transverse Wave
Transverse waves can be represented by a sine or cosine function called a wave function. The wave function determines the displacement of a particle from the axis of propagation at different times and distances from the origin. This displacement is proportional to the sine or cosine of the angle that the displacement vector makes with the axis. Examples of transverse waves include ripples on the water surface, vibrations on a guitar string, and seismic S-wave. Electromagnetic waves have transverse characteristics, but unlike other mechanical waves, they can propagate in a vacuum.