Interval Trees

Interval Trees - Interval Trees Store intervals of the...

This preview shows pages 1–6. Sign up to view the full content.

Interval Trees Store intervals of the form [ l i ,r i ], l i <= r i . Answer queries of the form: which intervals intersect/overlap a given interval [ l ,r] .

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Definition A binary tree. Each node v has a point v.pt and two lists v.left and v.right . Intervals with r i < v.pt are stored in the left subtree of v . Intervals with l i > v.pt are stored in the right subtree of v . u.pt < v.pt for nodes u in left subtree of v . u.pt > v.pt for nodes u in right subtree of v .
Definition Intervals with l i <= v.pt <= r i are stored in v . v.left has these intervals sorted by l i . v.right has these intervals sorted by r i .

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Example v.pt = 4 L = {a, e} R = {d} 1 e 1 3 a 2 4 c 4 6 b 3 6 f 5 7 d 2 4 L R v v.left = {c, f, b} v.right = {c,b,f}
Properties Each interval is stored in exactly one node. Each node stores between 1 and n intervals. Number of nodes is O(n) . Sum of sizes of left and right lists is O(n) .

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern