[英]Time complexity to insert a node at the end of circular linked list?
Time complexity to insert a node at the end of circular singly linked list containing N elements ? 在包含N个元素的圆形单链表的末尾插入节点的时间复杂度? Suppose I have pointer to the first node.
假设我有指向第一个节点的指针。
I think that it is O(N) as I have to parse the LL to the node before the new node to modify its next field. 我认为它是O(N),因为我必须在新节点修改其下一个字段之前将LL解析到节点。
Have I got it right ? 我做对了吗?
Adding to the end of a circular singly linked list can be done in O(1) time. 添加到循环单链表的末尾可以在O(1)时间内完成。
As these are all constant time operations, this procedure is O(1). 由于这些都是常量时间操作,因此该过程为O(1)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.