lec10 - Interval Heaps Complete binary tree Each...

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

View Full Document Right Arrow Icon
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.
Image of page 1

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

View Full Document Right Arrow Icon
Interval [c,d] is contained in [a,b] a <= c d <= b a b c d
Image of page 2
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.
Image of page 3

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

View Full Document Right Arrow Icon
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
Image of page 4
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.
Image of page 5

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

View Full Document Right Arrow Icon
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.
Image of page 6
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.
Image of page 7

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

View Full Document Right Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern