1,378 views
1 votes
1 votes

The Answer given is A) 

I think the naswer should be B) as we have both the prev pointer and the next pointer available , it will take constant time to update the adjacent nodes pointers and delete the given node .?

1 Answer

Best answer
4 votes
4 votes

If the pointer to the node to be deleted is given then worst case time complexity would be O(1). But since it is not given, we would have only pointer to the head. So before deleting we would have to search by traversing the LL. In worst case it might take O(n) and deleting would take only O(1). 

Thus O(n).

selected by

No related questions found