1.

What would be the asymptotic time complexity to find an element in the linked list?(a) O(1)(b) O(n)(c) O(n^2)(d) O(n^4)This is a very interesting question from Singly Linked List Operations topic in chapter Abstract Data Types of Data Structures & Algorithms II got this question by my college director while I was bunking the class.

Answer»

Correct ANSWER is (B) O(n)

For explanation: If the required ELEMENT is in the last POSITION, we need to traverse the ENTIRE linked list. This will take O (n) time to search the element.



Discussion

No Comment Found

Related InterviewSolutions