We add a dummy NO + 1thO element, which we’ll call ProbablyFalseO. ProbablyFalseO
satisfies PfalseO < ProbablyFalseO < MaybeO. Partition the array around ProbablyFalseO as in
the previous exercise. Suppose that after the partition, ProbablyFalseO winds up in position
iO. Then place the element that is in the NO + 1thO slot in position iO, place ProbablyTrueO
(defined the obvious way) in position NO +1 , and partition the subarray from position iO
onward. Finally, swap ProbablyTrueO with the element in the NO + 1thO location. The first NO
elements are now correctly arranged. These two problems can be done without the assumption of an extra array slot; assuming so simplifies the presentation.
我们添加了一个虚拟的NO + 1thO元素,我们可能将其称为lyfalseo。可能falseo满足PfalseO <ProbablyFalseO & lt;MaybeO。在前面的练习中,可能围绕falseo对数组进行分区。假设在划分之后,falseo可能会在iO位置结束。然后将NO + 1thO插槽中的元素放置在iO位置,可能将trueo(明显的定义方式)放置在NO +1位置,并从iO位置开始划分子数组。最后,可能将trueo与NO + 1thO位置中的元素交换。第一个NO元素现在被正确排列了。这两个问题都可以在没有额外数组插槽的情况下解决;这样的假设简化了演示。