
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
These notes provide an overview of the segment tree data structure, its properties, and how it is used to represent a finite set of line segments w.r.t. A left-closed right-open interval. The segment tree is a binary tree with each node implicitly representing a line segment and having an associated list of line ids. The root of the tree represents the interval [1,n] and nodes may have up to two children. The notes also cover the conditions for a node to have children and how a line segment is associated with a node.
Typology: Study notes
1 / 1
This page cannot be seen from the preview
Don't miss anything!

Suppose we are given a left-closed right-open interval I = [0,N). A line segment l w.r.t. the interval I is represented as a pair [B,E) where 0 < B <= E < N. Suppose L is a finite set of line segments w.r.t. I. Each line segment in L is assumed to have an associated id. All end points are assumed to be integers. A segment tree associated with I is a binary tree T having the following properties:
1. Each node n in the tree implicitly represents a line segment [ n .B, n .E). Note that the line segment implicitly associated with node n may not occur anywhere in L. 2. In addition, each node n has an associated list n .List of line id’s associated with lines in L. The list may be empty. 3. The root of T satisfies the condition Root(T).B = 1, Root(T).E = N. 4. If n is a node in T and n .B + 1 < n .E then: a. n may have upto two children b. ( n .left).B = n .B; ( n .left).E = n .B + ceil(( n .E – n .B)/2) c. ( n .right).B = ( n .left).E; ( n .right).E = n .E 5. Suppose l is a line-segment. n. LIST contains l .id iff: a. There is no ancestor n’ of n in tree T such that n’ .LIST contains l. id and b. [ n .B, n .E) is a subset (or equal to) the interval [ l.B,l. E ) , i.e. the interval associated with the node must be a subset of (or equal to) the line segment l ’s associated interval. When inserting lines into a segment tree, we only create the necessary nodes (i.e. every leaf in the segment tree must have at least one line-id labeling it at any given point in time).