编程语言
首页 > 编程语言> > 在哪里可以找到Java方法的时间复杂度?

在哪里可以找到Java方法的时间复杂度?

作者:互联网

我是Java新手,正在docs.oracle.com上学习各种方法,但很奇怪的是,他们没有提到那里描述的任何方法的时间复杂性,例如在此页上的:https://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html#get(int)
有一些有关“ get()”方法的信息,但没有有关复杂性的信息!我找不到合适的地方去问哪里可以找到有关复杂性的信息.也许有像cplusplus.com这样的信息,但我不知道.我在网上搜索失败.所以,如果这是愚蠢的问题,请原谅我.

解决方法:

在页面的最上方说

The size, isEmpty, get, set, iterator, and listIterator operations run in constant time. The add operation runs in amortized constant time, that is, adding n elements requires O(n) time. All of the other operations run in linear time (roughly speaking). The constant factor is low compared to that for the LinkedList implementation.

标签:time-complexity,java
来源: https://codeday.me/bug/20191026/1937427.html