小杨用单链表保存任务序列,并同时维护头指针 head 和尾指针 tail。在链表非空且已知 tail 的情况下,在表尾插入新结点的时间复杂度是( )。
head
tail
struct Node { int value; Node *next; }; Node *head; Node *tail;
O(1)O(1)O(1)
O(logn)O(\log n)O(logn)
O(n)O(n)O(n)
O(nlogn)O(n \log n)O(nlogn)