Radar and sonar are based on similar principles. Sonar (which stands for sound navigation and ranging) uses ultrasound, and radar (which stands for radio detecting and ranging) uses radio waves. Explain the principle of detecting and ranging in these applications.