lec11 - Leftist Trees Linked binary tree Can do everything...

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

View Full Document Right Arrow Icon
Leftist Trees Linked binary tree. Can do everything a heap can do and in the same asymptotic complexity. insert remove min (or max) initialize Can meld two leftist tree priority queues in O(log n) time.
Image of page 1

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

View Full Document Right Arrow Icon
Extended Binary Trees Start with any binary tree and add an external node wherever there is an empty subtree. Result is an extended binary tree.
Image of page 2
A Binary Tree
Image of page 3

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

View Full Document Right Arrow Icon
An Extended Binary Tree number of external nodes is n+1
Image of page 4
The Function s() For any node x in an extended binary tree, let s(x) be the length of a shortest path from x to an external node in the subtree rooted at x .
Image of page 5

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

View Full Document Right Arrow Icon
s() Values Example
Image of page 6
0 0 0 0 0 0 0 0 0 0 1 1 1 2 1 1 2 1 2 s() Values Example
Image of page 7

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

View Full Document Right Arrow Icon
Properties Of s() If x is an external node, then s(x) = 0 . Otherwise, s(x) = min {s(leftChild(x)), s(rightChild(x))} + 1
Image of page 8
Height Biased Leftist Trees A binary tree is a (height biased) leftist tree iff for every internal node x , s(leftChild(x)) >= s(rightChild(x))
Image of page 9

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

View Full Document Right Arrow Icon
A Leftist Tree 0 0 0 0 0 0 0 0 0 0 1 1 1 2 1 1 2 1 2
Image of page 10
Leftist Trees – Property 1 In a leftist tree, the rightmost path is a shortest root to external node path and the length of this path is s(root).
Image of page 11

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

View Full Document Right Arrow Icon
A Leftist Tree 0 0 0 0 0 0 0 0 0 0 1 1 1 2 1 1 2 1 2 Length of rightmost path is 2 .
Image of page 12
Image of page 13
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