Consider a segment tree built on an array of N elements. What is the time complexity of updating a range of elements in the segment tree?
(A)
O(log N)
(B)
O(N)
(C)
O(log N + K), where K is the number of elements in the range
(D)
O(N log N)
Answer: (B)
Explanation:
Updating a range of elements in a segment tree requires visiting each affected node, resulting in a time complexity of O(N).
Quiz of this Question
Please comment below if you find anything wrong in the above post
Article Tags :
Uncategorized
Recommended Articles