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

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

View Full Document Right Arrow Icon
MP4 available, EC due 3/4, due 3/11, 11:59p. Today: Trees Today’s announcements:
Background image of page 1

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

View Full DocumentRight Arrow Icon
Binary tree, recursive definition: A binary tree T is either OR
Background image of page 2
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):
Background image of page 3

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

View Full DocumentRight Arrow Icon
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 },
Background image of page 4
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?
Background image of page 5

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

View Full DocumentRight Arrow Icon
Background image of page 6
Background image of page 7

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

View Full DocumentRight Arrow Icon
Background image of page 8
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

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 Right Arrow Icon
Ask a homework question - tutors are online