What would be the asymptotic time complexity to insert an element at the front of the linked list (head is known)?
What would be the asymptotic time complexity to insert an element at the front of the linked list (head is known)? Correct Answer O(1)
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).
মোঃ আরিফুল ইসলাম
Feb 20, 2025