After underperforming for almost a year, stocks in the midcap and smallcap segments made a strong comeback and registered stellar gains in the last six months.