# lec10 - Interval Heaps Complete binary tree Each...

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

Interval Heaps Complete binary tree. Each node (except possibly last one) has 2 elements. Last node has 1 or 2 elements. Let a and b be the elements in a node P , a <= b . [a, b] is the interval represented by P . The interval represented by a node that has just one element a is [a, a] . The interval [c, d] is contained in interval [a, b] iff a <= c <= d <= b . In an interval heap each node’s (except for root) interval is contained in that of its parent.

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

View Full Document
Interval [c,d] is contained in [a,b] a <= c d <= b a b c d
Example Interval Heap 28,55 35 25,60 30,50 16,19 17,17 50,55 47,58 40,45 40,43 35,50 45,60 15,20 20,70 15,80 30,60 10,90 Left end points define a min heap. Right end points define a max heap.

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

View Full Document
28,55 35 25,60 30,50 16,19 17,17 50,55 47,58 40,45 40,43 35,50 45,60 15,20 20,70 15,80 30,60 10,90 Min and max elements are in the root. Store as an array. Height is ~log n . Example Interval Heap
Insert An Element 28,55 35 25,60 30,50 16,19 17,17 50,55 47,58 40,45 40,43 35,50 45,60 15,20 20,70 15,80 30,60 10,90 Insert 27 . 27,35 New element becomes a left end point. Insert new element into min heap.

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

View Full Document
Another Insert 28,55 35 25,60 30,50 16,19 17,17 50,55 47,58 40,45 40,43 35,50 45,60 15,20 20,70 15,80 30,60 10,90 Insert 18 . New element becomes a left end point. Insert new element into min heap.
28,55 25,35 25,60 30,50 16,19 17,17 50,55 47,58 40,45 40,43 35,50 45,60 15,20 20,70 15,80 30,60 10,90 Insert 18 . ,60 New element becomes a left end point.

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