原书出处
Introduction to Algorithms, Fourth Edition
17 第17章 数据结构的扩张
he number of nodes that come before x in an inorder tree walk of the subtree rooted at x.
Thus, x.left.size + 1 is the rank of x within the subtree rooted at x. If i = r, then node x is the ith smallest element, and so line 3 returns x. If i < r, then the ith smallest element resides in x’s left subtree, and therefore, line 5 recurses on x.left. If i > r, then the ith smallest element resides in x’s right subtree. Since the subtree rooted at x contains r elements that come before x’s right subtree in an inorder tree walk, the ith smallest element in the subtree rooted at x is the (i − r)th smallest element in the subtree rooted at x.right. Line 6 determines this element recursively.
OS-SELECT(x, i) 1 r = x.left.size + 1 // rank of x within the subtree rooted at x 2 if i
原书定位详情
来源:a19c7933-4eda-4176-aebd-30fe7e1ad292
正文位置:extracted/Introduction to Algorithms, Fourth Edition/_epub-src/OEBPS/chapter017.xhtml
EPUB SHA-256:ec7ced04bb875b93983816aef7a667855a4b71c5cf53b63406b9439c74e27aea