A p-n junction diode is used as a rectifier in a circuit, either in a DC circuit or an AC circuit. A rectifier is a device that converts AC to DC by allowing the flow of current in one direction and blocking it in the other direction. This is achieved by the p-n junction diode, which has a unique property of allowing current to flow in only one direction. Therefore, the p-n junction diode is widely used as a rectifier in various electronic circuits.