Dear student, First understand the formation of depletion layer in simple p - n junction diode. When a P-N junction is formed, the majority carriers at both sides near the junction diffuse to the opposite side. That is, electrons from the N-side diffuse towards the P-side and holes from the P-side diffuse towards the N-side. This diffusion leaves behind ionized donors on the N-side and ionized acceptors on the P-side. The ionized donors and acceptors are immobile, as they are bonded to the surrounding atoms of the crystal lattice. This layer of immobile ions is known as depletion region or space charge region. Diffusion of electron and holes from N and P sides respectively are halted after the formation of the depletion layer. The electric field within the depletion layer repels the diffusing of the majority carriers. This opposes the further diffusion of electrons and holes and widening of the depletion region. When the p - n side are heavily doped p side has more number of holes and n side has more number of electron. When p and n side are placed in contact then same thing will take place, but the difference is that diffusion rate increases as large numbers of charge carriers are present near the junction. Diffusion of electron and holes from N and P sides respectively are halted within the small region near the junction after the formation of the depletion layer, as large numbers of charge carriers are present. Therefore, the width of depletion region decreases due to this they are heavily doped. Regards