2c03-review - 00009

2c03-review - 00009 - 1 is not full, so T 2 is full and...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
3 8 T 1 inorder(T 1 )=1,4,9 T 2 inorder(T 2 )= 6,2,5,3,7,8 always full, and that height(T 1 )=height(T)-1, height(T 2 ) height(T)-1. Note also that if T 1 is not full than height(T 2 )=height(T)-2. Thus, in this case we have, height(T 1 )=3-1=2. If T 1 is full then the height 2 implies T 1 has 4 leafs at the bottom level. Since T is complete that it is full if we cut all the leaves at the bottom level. The total number of nodes is number-of- leaves-at-the-bottom-level + (2 h -1), so if T 1 has 4 leafs at the bottom level, then this number is greater or equal to 4+2 3 -1=11>9, which means that T
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1 is not full, so T 2 is full and height(T 2 )=height(T)-2=3-2=1, which T 2 has exactly 3 elements. Thus the last 3 elements of our inorder are the inorder of the full tree, the 4 th element from the right is the root of T, the elements on the left of the root of T are the inorder of T 2 which is a complete tree. Hence: Since T 1 is full then one may easy find out that ROOT(T 1 )= 4, LEFT(ROOT(T 1 ))=1, RIGHT(ROOT(T 1 ))=9. For T 2 we repeat the same reasoning as for T. Finally out three T is:...
View Full Document

This note was uploaded on 12/10/2009 for the course CAS 2c03 taught by Professor Janicki during the Spring '03 term at McMaster University.

Ask a homework question - tutors are online