测评会员优惠活动进行中 · 开通 VIP,有效期内测评不限次 VIP 优惠中 · 测评不限次 立即查看

A18702. 下面代码段实现了快速排序的划分操作(以首元素为基准),横线处代码应填入( )。def partition(arr, low, high): pivot = arr[low] i = low j = high while i < j: while i < j and arr[j] >= pivot: j -= 1 while i < j and arr[i] <= pivot: i += 1 if…

单选题 困难

题目描述

下面代码段实现了快速排序的划分操作(以首元素为基准),横线处代码应填入(    )。

def partition(arr, low, high):
    pivot = arr[low]
    i = low
    j = high
    while i < j:
        while i < j and arr[j] >= pivot:
            j -= 1
        while i < j and arr[i] <= pivot:
            i += 1
        if i < j:
            arr[i], arr[j] = arr[j], arr[i]
    ________________ # 在此处填入代码
    return i

选项(单选)

上一题 下一题