I have following task:
In the program we should draw lines on a bit mapped display. An array of
n
pairs of reals(ai,bi)
defined then
linesyi = ai*x + bi
. The lines were ordered in thex
-interval[0, 1]
in the sense thatyi < yi+1
for all values ofi
between0
andn-2
and for all values ofx
in[0, 1]
Less formally, the lines don't touch in the vertical slab. Given a point (x,y)
, where 0 < x < 1
, we want to determine two lines that bracket the point.
How can we solve this problem quickly?