Questions tagged [segment-tree]

A segment tree is a heap-like data structure that can be used for making update/query operations upon array intervals in logarithmical time.

A segment tree is a balanced tree where each node corresponds to an interval. The leaves correspond to the atomic intervals according to left to right order. An internal node u corresponds to the union of the intervals corresponding to the leaves of the subtree rooted at u.

A segment tree for a set of n intervals can be constructed in O(nlogn) time.

A d-dimensional segment tree for a set of n axis-aligned rectangular boxes in R d can be built in O(n(logn)^ d ) time and takes O(n(logn)^ d ) space.

273 questions
-5
votes
1 answer

Insert and Search in Segment tree

So the problem states like this,we have an array and we should do 2 types of operations: 1) Adding value v,on segment [x,y] 2) Finding sum on segment [x,y] I was searching for the answer but couldn't find anything,if you have any useful links or…
filo
  • 1
-7
votes
1 answer

How can we find number of distinct elements in a given submatrix?

Given a N*N matrix and Q queries for the same given matrix. Each Query is of form x1,y1,x2,y2. We have to find the number of distinct elements in the sub-matrix defined by (x1,y1) and (x2,y2) as top left and bottom right corner…
SuperCoder
  • 121
  • 1
  • 14
1 2 3
18
19