Python中list.index(x)的复杂性 [英] Complexity of list.index(x) in Python
问题描述
我指的是: http://docs.python.org/tutorial/datastructures .html
以大O表示,list.index(x)
函数的运行时间是多少?
What would be the running time of list.index(x)
function in terms of big O notation?
推荐答案
It's O(n), also check out: http://wiki.python.org/moin/TimeComplexity
本页记录了当前CPython中各种操作的时间复杂性(又名"Big O"或"Big Oh").其他Python实现(或CPython的较早版本或仍在开发中的版本)的性能特征可能略有不同.但是,通常可以安全地假设它们的速度不超过O(log n)...
This page documents the time-complexity (aka "Big O" or "Big Oh") of various operations in current CPython. Other Python implementations (or older or still-under development versions of CPython) may have slightly different performance characteristics. However, it is generally safe to assume that they are not slower by more than a factor of O(log n)...
这篇关于Python中list.index(x)的复杂性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!