This preview shows pages 1–6. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: 141/17Trees and tree terminologyBinary treesTree traversals Implementations of treesCSE 12Binary Tree Properties142/17Binary TreesA binary treeis a tree with an arity of 0, 1 or 2 a node may have 0, 1, or 2 children (a) A full binary tree of height 3.(b) Complete binary trees of height 3 and 4.A full binary treeof height h is one in which all nodes from level 1 to level h 1 have two children A complete binary treeof height his one in which all nodes from level 1 to h 2 have two children and all the children of nodes at level h 1 are contiguous and to the left of the tree 143/17Binary Tree propertiesConsider a full binary tree (every level that has any nodes at all has as many nodes as possible):How many nodes at level 1? ____How many nodes at level 2? ____How many nodes at level 3? ____ Generalizing, how many nodes at level L? ____And so, how many nodes in a full binary tree of height h? __________And so, what is the height of a full binary tree with n nodes?________144/17Binary Tree propertiesGeneralizing, how many nodes at level L?And so, how many nodes in a full binary tree of height h?And so... what is the height of a full binary tree of size n?2L1n=L=1h2L1=2h1( )( )n=h+n=hn=hlog1log122145/17Binary Tree propertiesProperty 10.1 A full binary tree of height hhas 2h 1 nodesProperty 10.2 The height of a full binary tree with nnodes is. (This is also the length of the longest path in a full binary tree.)Property 10.3 The height of a binary tree with nnodes is at least and at most n (this worst case occurs when no node has more than 1 child)....
View
Full
Document
This note was uploaded on 06/15/2011 for the course ECON 1 taught by Professor Aben during the Fall '07 term at City College of San Francisco.
 Fall '07
 Aben

Click to edit the document details