Answer
The algorithm finds the best fitting line by minimizing the difference between predicted values and actual values, usually measured as the sum of squared errors, using a method called least squares.
Real-world example A real estate company predicts house prices based on square footage, using linear regression to estimate how much price increases for each additional square foot.