This preview shows page 1. Sign up to view the full content.
Unformatted text preview: end procedure PrintPre(T:Tree, m:1. .max) begin if m>T.n then return; write(T.lables[m]); PrintPre(T, 2*m); PrintPre(T, 2*m+1) end b. O(n). Since every node is visited only one time. 6. The complete tree with 9 nodes is in this shape: a b c d e f g h i j The preorder is a, b, d, h, i, j, e, c, f, g 1, 2, 3, 4, 5,6, 7,8, 9, 10...
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.
- Spring '03