# lec0307-trees - Complete tree of height h C h • an empty...

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

MP4 available, EC due 3/4, due 3/11, 11:59p. Today: Trees Today’s announcements:

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

View Full Document
Binary tree, recursive definition: A binary tree T is either OR
An (important) example of a function on a binary tree: height(t) -- length of longest path from root to a leaf Given a tree T, write a recursive defn of the height of T, height(T):

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

View Full Document
Full Binary tree: a tree in which every node has 2 or 0 children Full tree of height h, F h : • F -1 is an empty tree • if h > -1, then F h is {r, T L , T R },
Complete Binary tree: all leaves are at level height(t) or height(t) -1, and all leaves at level height(t) are pushed to the left. Check for understanding: Is every full tree complete? Is every complete tree full?

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

View Full Document

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Complete tree of height h, C h : • an empty tree is C-1 • if h > -1, then C h is {r, T L , T R }, and either: T L is _______ and T R is ________ OR T L is _______ and T R is ________ P : P 1 : P 2 : Perfect tree of height h, P h : • P-1 is an empty tree • if h > -1, then P h is {r, T L , T R }, where T L and T R are P h-1 . Rooted, directed, ordered, binary trees ADT: insert remove traverse template <class T> class tree{ public: … private: struct treeNode{ T data; treeNode * left; treeNode * right; }; treeNode * root … }; Implementation: Theorem: if there are n data items in a binary tree, then there are ______ null pointers....
View Full Document

{[ snackBarMessage ]}

### Page1 / 8

lec0307-trees - Complete tree of height h C h • an empty...

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

View Full Document
Ask a homework question - tutors are online