Question discussion

In a singly linked list that keeps only a head pointer, inserting a new node at the end of the list takes

1746Medium DSSSB TGT Computer Science 0 replies 1 views
0

In a singly linked list that keeps only a head pointer, inserting a new node at the end of the list takes

  • AO(1) time
  • BO(log n) time
  • CO(n²) time
  • DO(n) time
Correct answer: D

Explanation

Without a tail pointer the whole list must be traversed to reach the last node.

Discussion 0

Nobody has replied yet. Start the discussion!