← 返回卡片

原书出处

Introduction to Algorithms, Fourth Edition

26 第26章 并行算法

Fourth edition · 核验版本的摘录快照 · 导入于 2026-10-23T08:18:08.746Z

, p, r, x) on the next page, which takes as input a sorted subarray A[p : r] and a key x.

The procedure returns a split point of A[p : r]: an index q in the range p ≤ q ≤ r + 1 such that all the elements in A[p : q − 1] (if any) are at most x and all the elements in A[q : r] (if any) are at least x. The FIND-SPLIT-POINT procedure uses binary search to find the split point. Lines 1 and 2 establish the range of indices for the search. Each time through the while loop, line 5 compares the middle element of the range with the search key x, and lines 6 and 7 narrow the search range to either the lower half or the upper half of the subarray, depending on the result of the test. In the end, after the range has been narrowed to a single index, line 8 returns that index as the split point.

FIND-SPLIT-POINT (A, p, r, x) 1 low = p // low end of search range 2 high = r + 1 // high

此预览只包含定位所需的摘录和上下文。

原书定位详情

来源:a19c7933-4eda-4176-aebd-30fe7e1ad292

正文位置:extracted/Introduction to Algorithms, Fourth Edition/_epub-src/OEBPS/chapter026.xhtml

EPUB SHA-256:ec7ced04bb875b93983816aef7a667855a4b71c5cf53b63406b9439c74e27aea