# DS05_Ch04b - 2 Binary Trees Note: IIna tree, the order of...

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

§2 Binary Trees Note: In a tree, the order of children does not matter. But in a binary tree, left child and right child are different. Note: In a tree, the order of children does not matter. But in a binary tree, left child and right child are different. A B A B and are two different binary trees. Skewed Binary Trees A B C D A B C D Skewed to the left Skewed to the right Complete Binary Tree A C G B D H E F I All the leaf nodes are on two adjacent levels 1/14

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

View Full Document
Properties of Binary Trees §2 Binary Trees The maximum number of nodes on level i is 2 i - 1 , i 1. The maximum number of nodes in a binary tree of depth k is 2 k - 1 , k 1. For any nonempty binary tree, n 0 = n 2 + 1 where n 0 is the number of leaf nodes and n 2 the number of nodes of degree 2 . Proof: Let n 1 be the number of nodes of degree 1 , and n the total number of nodes. Then n = 2 1 0 n n n + + Let B be the number of branches. Then n ~ B ? n = B + 1. Since all branches come out of nodes of degree 1 or 2, we have B ~ n 1 & n 2 ? B = n 1 + 2 n 2 . 1 2 3 n 0 = n 2 + 1 Home work: p.139 4.42 Isomorphic Trees p.140 4.45 Threaded Trees 2/14
Bonus Problem 1 Population (2 points) Due: Wednesday, September 24 th , 2008 at 10:00pm Detailed requirements can be downloaded from http://10.71.45.98/hqm/ykj/notes/describe.htm Courseware Download 3/14

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

View Full Document
§3 The Search Tree ADT -- Binary Search Trees Definition A binary search tree is a binary tree. It may be empty. If it is not empty, it satisfies the following properties: (1) Every node has a key which is an integer , and the keys are distinct .
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 10/20/2011 for the course COMPUTER S 10586 taught by Professor Jilinwang during the Spring '09 term at Zhejiang University.

### Page1 / 14

DS05_Ch04b - 2 Binary Trees Note: IIna tree, the order of...

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

View Full Document
Ask a homework question - tutors are online