1.

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 II had been asked this question in an international level competition.

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



Discussion

No Comment Found

Related InterviewSolutions