Recently I had a phone interview at Google and was asked this question below.
Given two coordinates (x1, y1) and (x2, y2) draw a straight line between them.
You are given a method function(x,y) that you will call to draw a pixel.
Formulae given ->
y = mx + c and m = (y2-y1)/(x2-x1)
I spent around 20 minutes trying to find the intermedite coordinates between the two input coords.
I know m and c are constants and we can derive the values using
c = y - mx
and m using the above formula. But how does one find new x and y values using these information? Clearly, I was unable to solve the question.
EDIT : Got called for virtual onsite as the recruiter told me that the interviewer liked my thought process even though I didn't solve the question.