python查找第k小元素代码分享

代码如下:

# -*- coding: utf-8 -*-

from random import randintfrom math import ceil, floor

def _partition(a, l, r, i): “””以a[i]为主元划分数组a[l..r],使得: a[l..m-1]