# 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.

## This note was uploaded on 12/07/2010 for the course COT 5536 taught by Professor Sartajsahani during the Spring '10 term at University of Florida.

### Page1 / 34

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

This preview shows document pages 1 - 13. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online