{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lec14 - 14-1/17•Trees and tree terminology•Binary...

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 Document Right Arrow Icon

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

View Full Document Right Arrow Icon

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

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

Unformatted text preview: 14-1/17•Trees and tree terminology•Binary trees•Tree traversals •Implementations of treesCSE 12Binary Tree Properties14-2/17Binary Trees•A 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 properties•Consider 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 properties•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 of size n?2L−1n=∑L=1h2L−1=2h−1( )( )n=h+n=hn=hlog1log122Θ−14-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

{[ snackBarMessage ]}

Page1 / 16

lec14 - 14-1/17•Trees and tree terminology•Binary...

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

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