What would be the asymptotic time complexity to add a node at the end of singly linked list, if the pointer is initially pointing to the

Phương Quyên

New member
What would be the asymptotic time complexity to add a node at the end of singly linked list, if the pointer is initially pointing to the head of the list?
A. O(1)
B. O(n)
C. θ(n)
D. θ(1)
 
Answer: C
Explanation: In case of a linked list having n elements, we need to travel through every node of the list to add the element at the end of the list. Thus asymptotic time complexity is θ(n).
 

Tìm kiếm

Back
Top