高效地在python的未排序列表中获取第k个最小元素 [英] Efficiently get kth smallest element in unsorted list in python

查看:353
本文介绍了高效地在python的未排序列表中获取第k个最小元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何快速/有效的方法可以解决此问题?

Is there any fast/efficient method available for solving this problem?

我可以在O(nlogn)中完成它,但是我期望更快的解决方案.

I can do it in O(nlogn) but faster solution I am expecting.

推荐答案

您正在寻找选择算法,该操作在O(n)

You are looking for Selection algorithm, which is done in O(n)

这篇关于高效地在python的未排序列表中获取第k个最小元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆