Step 1 — Why the classes must be made continuous first
Look at the classes as given: 118–126, then 127–135. There is a gap between 126 and 127.
That gap exists because the lengths were rounded to the nearest millimetre — a leaf recorded as 126 mm could really be anything from 125.5 to 126.5 mm. The median formula assumes the classes run into one another with no gaps, so you must close them.
The gap is 127−126=1, so take half of it, 0.5, from each lower limit and add it to each upper limit:
118−0.5=117.5and126+0.5=126.5
Step 2 — The corrected table
| Length (in mm) | Frequency f | Cumulative frequency |
|---|
| 117.5 – 126.5 | 3 | 3 |
| 126.5 – 135.5 | 5 | 8 |
| 135.5 – 144.5 | 9 | 17 |
| 144.5 – 153.5 | 12 | 29 |
| 153.5 – 162.5 | 5 | 34 |
| 162.5 – 171.5 | 4 | 38 |
| 171.5 – 180.5 | 2 | 40 |
| Total | 40 | |
Note that the class size is now 126.5−117.5=9, the same as before. Making the classes continuous shifts them, it does not stretch them.
Step 3 — Locate the median class
n=40⇒2n=20
Cumulative frequencies: 3,8,17,29. The first to reach 20 is 29, so the median class is 144.5 – 153.5.
Step 4 — Apply the formula
l=144.5,cf=17,f=12,h=9
Median=l+(f2n−cf)×h
=144.5+(1220−17)×9
=144.5+123×9=144.5+1227
=144.5+2.25
Median length=146.75 mm
The habit to build
Whenever you see classes with gaps — 1–4, 5–8, or 118–126, 127–135 — stop and close the gaps before using the median or mode formula. Using 145 instead of 144.5 here would have given 147.25 mm, half a millimetre out.