In a linked list with $n$ nodes, the time taken to insert an element after an element pointed by some pointer is: $(A) O(1)$ $(B) O(logn)$ $(C) O(n)$ $(D) O(nlogn)$
@Verma Ashish
see my above comment.
Yeah, it takes $O(1)$ times because already some pointer pointed to the element.(If some pointer does not point the element and we want to insert the element at the end of the linked list(tail sometimes it is called rear of the linked list) , it takes $O(n)$, because we traverse the entire list, from the start node(head, sometimes it is called front of the linked list)
64.3k questions
77.9k answers
244k comments
80.0k users