algorithm - worst case running time of segment tree -
how range sum in segment tree o(logn) worst case?? shouldn't o(n)? if during range sum operation,we traverse down both left , right nodes per algorithm?
lets call active
node node stores interval neither included in interval nor covered interval. easy spot there @ 2 active nodes on each level traverse. if node not active not need recurse in - if interval covered add value written in node, if interval not intersect 1 interested in skip it. number of operations algorithm perform in order of levels of tree or o(log(n))
.
Comments
Post a Comment