CameraIcon
CameraIcon
SearchIcon
MyQuestionIcon
MyQuestionIcon
1
You visited us 1 times! Enjoying our articles? Unlock Full Access!
Question

Let P be a singly linked list. Let Q be the pointer to an intermediate node x in the list. What is the worst-case time complexity of the best-known algorithm to delete the node x form the list?

A
O(logn)
No worries! We‘ve got your back. Try BYJU‘S free classes today!
B
O(n)
Right on! Give the BNAT exam to get a 100% scholarship for BYJUS courses
C
O(1)
No worries! We‘ve got your back. Try BYJU‘S free classes today!
D
O(log2n)
No worries! We‘ve got your back. Try BYJU‘S free classes today!
Open in App
Solution

The correct option is B O(n)
To delete node x, we should find out the previous node to the x. To find the previous nodes to the x will take O(n).
Therefore it takes O(n).

flag
Suggest Corrections
thumbs-up
1
similar_icon
Similar questions
View More
Join BYJU'S Learning Program
similar_icon
Related Videos
thumbnail
lock
QUANTITATIVE APTITUDE
Watch in App
Join BYJU'S Learning Program
CrossIcon