Explain the charging and discharging behavior of an RC circuit. How is this concept applied to debounce a physical switch?