Semiconductors in which the number of electrons ne is equal to the number of holes nh are intrinsic semiconductors.
When a small amount of suitable impurity is added to the intrinsic semiconductor we can convert it into an extrinsic semiconductor of either p-type or n-type. Doping changes the concentration of charge carriers in the element.
i) P- type: When Si or Ge is doped with any trivalent impurity like Al, B etc we get a p-type semiconductor. The dopant has one valence electron less. Thus, this atom form covalent bond with the neighbouring three atoms and, is less of one electron to offer to the fourth silicon atom and as a result there is a vacancy. Hence, an electron in the outer orbit of the neighbouring atom may jump to fill this vacancy leaving a vacancy or hole at it's own site. This hole is the conducting charge carrier. Therefore, doping with a trivalent impurity gives us p-type semiconductor.
Energy band diagram for a p-type semiconductor is as shown below:

ii) n - type: When we dope Si or Ge with pentavalent impurities like As, P then four electrons of this atom will form covalent bonds with the neighbouring Si atom in the lattice. Whereas, the fifth electron will remain loosely bound to it's parent atom. Hence, the ionisation energy which is required to make this electron free is very less and it will move around even in room temperature. Thus, the pentavalent dopant will donate one extra electron for conduction and this acts as an n-type semiconductor.
Energy band diagram for n-type semiconductor is as shown below:
