[英]time complexity of this while loop
Hi I have written such a this code and I want to know that : its time complexity is O(n) ? 嗨,我已经编写了这样的代码,我想知道:它的时间复杂度为O(n)?
DNode header = new DNode(null, null, null);
DNode trailer = new DNode(null, header, null);
header.next = trailer;
for (Point point : pointList) {
DNode node = new DNode(point, header, trailer);
dList.addLast(node);
header = node;
}
I want to copying all objects from the pointList(ArrayList)
to a dList(Doubly-Linked list)
. 我想将所有对象从
dList(Doubly-Linked list)
pointList(ArrayList)
复制到dList(Doubly-Linked list)
。 thanks 谢谢
Yes. 是。 There's only one obvious loop here, which is O(n) - and everything within the loop is O(1), assuming a sensible implementation of the doubly-linked list.
这里只有一个明显的循环,即O(n)-假设双链表的明智实现,循环中的所有事物都是O(1)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.