Question:

The worst-case time complexity of inserting a node in a doubly linked list is:

Show Hint

Doubly linked lists allow constant-time insertion when the node reference is provided, unlike arrays that require shifting.
Updated On: Dec 29, 2024
  • O(n log n)
  • O(log n)
  • O(n)
  • O(1)
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is D

Solution and Explanation

In a doubly linked list: - Insertion at a known position is O(1) because the pointers to the previous and next nodes are updated directly. - The only traversal required is to locate the insertion point if not directly known, but in the worst case, for an insertion operation itself, the complexity is O(1).
Was this answer helpful?
0
0

Top Questions on Programming and Data Structures

View More Questions