演算法›Ch2 分治法
第 11 題/共 12 題
◀ AL 11/12
11. Convex Polygon、Binary Search、Algorithm Correctness
#AL-02-011中Convex PolygonBinary SearchAlgorithm Correctness
題組題幹(本題:㉑,共 3 小題)點擊展開

Consider binary search for finding extremal points of a convex polygon in the given direction.

Let Q be a convex polygon, represented by the vertices of its boundary in clockwise order, say, for example, Q=p1,p2,…,pnQ=p_1,p_2,\ldots,p_n with p1=pnp_1=p_n and n≥3n\ge 3, and let ℓ⃗\vec\ell be a given vector. See Figure (a) for an illustration. Consider the projection of points in Q onto ℓ⃗\vec\ell. For any two points q,r∈Qq,r \in Q, we write q≺ℓrq \prec_\ell r, if the projection of r lies further from the starting end of ℓ⃗\vec\ell than the projection of q. See Figure (b) for an illustration, where p5p_5 is further than p4p_4 in the direction of ℓ⃗\vec\ell.

A point q∈Qq \in Q is said to be maximal with respect to ℓ⃗\vec\ell if there exists no point r∈Qr \in Q such that q≺ℓrq \prec_\ell r. Similarly, a point q∈Qq \in Q is minimal with respect to ℓ⃗\vec\ell if there exists no r∈Qr \in Q such that r≺ℓqr \prec_\ell q. For example, in Figure (a), both p1p_1 and p6p_6 are maximal points of Q and p4p_4 is the minimal point of Q.

Let δ(Q)\delta(Q) denote the boundary of the convex polygon Q and consider the properties of Q.

Consider the following sketch of pseudo-code that aims to compute a maximal point of Q for the given direction ℓ⃗\vec\ell by binary search.

a ← 0, b ← n.  // to search the range [1,...,n-1]
While a < b - 1, repeat the following.
    c ← ⌊(a+b)/2⌋.
    Set b ← c if [a,c] contains a maximal point of Q in the direction ℓ⃗.
    Otherwise, set a ← c.
Output a if it is maximal. Otherwise, output b.

Regarding the above algorithm, which of the following statements is/are true?

題目附圖
📄 交大113
跳轉到第題
▤完整推導請見《WH 資工筆記 · 演算法》Ch2 分治法
本章題號 · 1–12 / 12