Sum of heights = 159 + 148 + 138 + 150 + 165 + 166 + 145 + 152 + 155 + 160 + 147 + 151
= 1836.
Number of students in n = 12.
\(\therefore\) Mean \(= \frac{\text{sum of heights}}{\text{number of students}}\) \(= \frac{1836}{12} = 153\,\text{cm}.\)
Ascending order of heights is 138, 145, 147, 148, 150, 151, 152, 155, 159, 160, 165, 166.
n = 12 = even
\(\therefore\) Median \(= \frac{1}{2}\left(\frac{n}{2}^{th} \left(\frac{n}{2} + 1\right)^{th}\right)\) terms in ascending order
\(= \frac{1}{2}\left(6^{th} + 7^{th}\, \text{terms}\right)\)
\(= \frac{1}{2}\left(151 + 152\right)\) = 151.5 cm.