本文介绍了Java ArrayList的时间复杂度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现这个问题的其他条目涉及具体的方法,但没有什么全面的。我想验证自己对这种数据结构最常用的方法的理解:

I found other entries for this question that dealt with specific methods, but nothing comprehensive. I'd like to verify my own understanding of the most often used methods of this data structure:

O(1) - 常数时间:

O(1) - Constant Time:

isEmpty()
add(x)
add(x, i)
set(x, i)
size()
get(i)
remove(i)

O(N) - 线性时间:

O(N) - Linear Time:

indexof(x)
clear()
remove(x)
remove(i)

这是正确的吗?感谢您的帮助。

Is this correct? Thanks for your help.

推荐答案

最好的资源是直接从:

这篇关于Java ArrayList的时间复杂度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-18 14:29