Question: Suppose we are given an array, A, of n nonintersecting segments, s 1 , s 2 ,...,s n , with endpoints on the lines y
Suppose we are given an array, A, of n nonintersecting segments, s1, s2,...,sn, with endpoints on the lines y = 0 and y = 1, and ordered from left to right. Given a point q with 0 < y(q) < 1, design an algorithm that in O(log n) time computes the segment si of A immediately to right of q, or reports that q is to the right of all the segments.
Step by Step Solution
3.43 Rating (156 Votes )
There are 3 Steps involved in it
We can use a binary search to locate q The important observation is that the segmen... View full answer
Get step-by-step solutions from verified subject matter experts
