13-Trees - Trees Trees Nonlinear Containers Containers we...

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

View Full Document Right Arrow Icon
Trees Trees
Background image of page 1

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

View Full DocumentRight Arrow Icon
Containers we have studied so far are linear. To represent nonlinear, i.e. hierarchal data we use trees. Nonlinear Containers Nonlinear Containers root node node leaf edge edge edge
Background image of page 2
Tree Terminology Tree Terminology root parent node child node leaf (no children) sub-tree Binary Tree: two child nodes Oct-tree: eight child nodes, etc. Huffman Tree: binary tree of codes of characters that might appear in the encoded message
Background image of page 3

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

View Full DocumentRight Arrow Icon
Tree Terminology, cont’d Tree Terminology, cont’d Complete Tree Incomplete Tree Full Tree
Background image of page 4
If the tree is empty (i.e. leaf) then return Else for each child node traverse sub-tree end for End if Tree Traversal (Recursive) Tree Traversal (Recursive)
Background image of page 5

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

View Full DocumentRight Arrow Icon
Preorder: process root node, traverse left sub-tree, traverse right sub-tree Node processing order: a b d e c Binary Tree Preorder Traversal Binary Tree Preorder Traversal a b c d e
Background image of page 6
Inorder: traverse left sub-tree, process root node, traverse right sub-tree Node processing order: d b e a c Binary Tree Inorder Traversal Binary Tree Inorder Traversal a b c d e
Background image of page 7

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

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

This note was uploaded on 03/18/2010 for the course CSE 122 taught by Professor Yoxheimer,ericch during the Spring '07 term at Pennsylvania State University, University Park.

Page1 / 15

13-Trees - Trees Trees Nonlinear Containers Containers we...

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

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