Answer
If the SI units are correct the dimensions are also correct. For a liquid:-
$\sqrt \frac{N/m^{2}}{kg/m^{3}}=\sqrt \frac{N.m}{kg}=\sqrt \frac{kg.m^{2}/s^{2}}{kg}=m/s$
Y has same units as B, so the expression for solid is also dimensionally correct.
Work Step by Step
If the SI units are correct the dimensions are also correct. For a liquid:-
$\sqrt \frac{N/m^{2}}{kg/m^{3}}=\sqrt \frac{N.m}{kg}=\sqrt \frac{kg.m^{2}/s^{2}}{kg}=m/s$
Y has same units as B, so the expression for solid is also dimensionally correct.