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

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

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.

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

View Full Document
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.
A Binary Tree

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

View Full Document
An Extended Binary Tree number of external nodes is n+1
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 .

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

View Full Document
s() Values Example
0 0 0 0 0 0 0 0 0 0 1 1 1 2 1 1 2 1 2 s() Values Example

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

View Full Document
Properties Of s() If x is an external node, then s(x) = 0 . Otherwise, s(x) = min {s(leftChild(x)), s(rightChild(x))} + 1
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))

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

View Full Document
A Leftist Tree 0 0 0 0 0 0 0 0 0 0 1 1 1 2 1 1 2 1 2
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).

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

View Full Document
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 .
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