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

Info iconThis 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.
Background image of page 1

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

View Full DocumentRight 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.
Background image of page 2
A Binary Tree
Background image of page 3

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

View Full DocumentRight Arrow Icon
An Extended Binary Tree number of external nodes is n+1
Background 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 .
Background image of page 5

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

View Full DocumentRight Arrow Icon
s() Values Example
Background 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
Background image of page 7

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

View Full DocumentRight 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
Background 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))
Background image of page 9

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

View Full DocumentRight Arrow Icon
A Leftist Tree 0 0 0 0 0 0 0 0 0 0 1 1 1 2 1 1 2 1 2
Background 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).
Background image of page 11

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

View Full DocumentRight 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 .
Background image of page 12
Image of page 13
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 Right Arrow Icon
Ask a homework question - tutors are online