+1 vote
in Data Structures & Algorithms I by (110k points)
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)

Question is from Singly Linked List Operations in portion Abstract Data Types of Data Structures & Algorithms I

I had been asked this question in an international level competition.

1 Answer

+1 vote
by (412k points)
selected by
 
Best answer
Right choice is (c) θ(n)

Best 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).

Related questions

Welcome to TalkJarvis QnA, a question-answer community website for the people by the people. On TalkJarvis QnA you can ask your doubts, curiosity, questions and whatever going in your mind either related to studies or others. Experts and people from different fields will answer.

Categories

...