Back to problems

Linear Interpolation of Missing Points

Algorithm · Datadog · Medium

You receive a positive integer interval together with a 2D integer array points. Each entry has the form [x, y] and denotes a location on the Cartesian plane. The entries are already arranged by x in strictly increasing order. Examine each neighboring pair [x1, y1] and [x2, y2]. Whenever x2 - x1 exceeds interval, add the points that are absent between them so that successive x-coordinates differ by exactly interval, beginning at x1 and reaching x2. For every pair that…

Checking your access…