The given observations are already in ascending order. Adding a row corresponding to cumulative frequencies $(c.f.)$ to the given data:
| $x_i$ | $3$ | $6$ | $9$ | $12$ | $13$ | $15$ | $21$ | $22$ |
| $f_i$ | $3$ | $4$ | $5$ | $2$ | $4$ | $5$ | $4$ | $3$ |
| $c.f.$ | $3$ | $7$ | $12$ | $14$ | $18$ | $23$ | $27$ | $30$ |
Now,$N = 30$,which is even.
Median is the mean of the $15^{\text{th}}$ and $16^{\text{th}}$ observations. Both of these observations lie in the cumulative frequency $18$,for which the corresponding observation is $13$.
Therefore,Median $M = \frac{15^{\text{th}} \text{ observation} + 16^{\text{th}} \text{ observation}}{2} = \frac{13+13}{2} = 13$.
Now,absolute values of the deviations from median,$|x_i - M|$,are calculated:
| $|x_i - M|$ | $|3-13|=10$ | $|6-13|=7$ | $|9-13|=4$ | $|12-13|=1$ | $|13-13|=0$ | $|15-13|=2$ | $|21-13|=8$ | $|22-13|=9$ |
| $f_i$ | $3$ | $4$ | $5$ | $2$ | $4$ | $5$ | $4$ | $3$ |
| $f_i|x_i - M|$ | $30$ | $28$ | $20$ | $2$ | $0$ | $10$ | $32$ | $27$ |
We have $\sum f_i = 30$ and $\sum f_i|x_i - M| = 30+28+20+2+0+10+32+27 = 149$.
Therefore,$M.D.(M) = \frac{1}{N} \sum f_i|x_i - M| = \frac{149}{30} = 4.966... \approx 4.97$.