in DS recategorized by
320 views
6 votes
6 votes

What is the run-time complexity of inserting a new element at the beginning of a circular, doubly-linked list with a head?

  1. $O(1)$
  2. $O(\log \text{N})$
  3. $O(\text{N})$
  4. $O(\text{N}^2)$
in DS recategorized by
320 views

2 Answers

12 votes
12 votes

This can be done in constant Time

1 vote
1 vote
O(1)

We need to change only the links. No need to traverse the linked list hence no loops.
Answer:

Related questions