Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

What would be the asymptotic time complexity to insert an element at the front of the linked list (head is known)?

a) O(1)
b) O(n)
c) O(n2)
d) O(n3)

Answer: a
Explanation: To add an element at the front of the linked list, we will create a new node which holds the data to be added to the linked list and pointer which points to head position in the linked list. The entire thing happens within O (1) time. Thus the asymptotic time complexity is O (1).

Join The Discussion