lec14 - 14-1/17Trees and tree terminologyBinary treesTree...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 14-1/17Trees and tree terminologyBinary treesTree traversals Implementations of treesCSE 12Binary Tree Properties14-2/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 14-3/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?________14-4/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=hlog1log12214-5/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.

Page1 / 16

lec14 - 14-1/17Trees and tree terminologyBinary treesTree...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online