It must be given whether the defected ball is lighter than others or heavier than others. Otherwise, it is not possible to solve it in 3 weightings.
This problem also illustrates the binary division approach.
Let us say the ball is lighter than other balls.
Take any six balls on one side and the remaining six on the other side of balance (weighting machine).
One side goes up. So lighter ball is in that group of six balls. Keep the other six (good) balls aside.
From the lighter group of 6 balls, keep 3 balls on side of balance and 3 on the other side. One side goes up. So keep the heavier set of 3 balls away.
Take the 3 balls which were lighter. Pick any two, put one on one side of weighting machine and another on the other side. One ball is in hand. There are two possibilities.
Both balls weigh equally. Then the ball in hand is the lighter ball.
One of the balls weighs less. Then that ball is what we are looking for.
So problem is solved.