Trees-handouts-2-color

Trees-handouts-2-color - Trees 1/11/2006 10:04 PM Trees...

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

View Full Document Right Arrow Icon
Trees 1/11/2006 10:04 PM 1 Trees 1 Trees Make Money Fast! Stock Fraud Ponzi Scheme Bank Robbery Trees 2 Outline and Reading Tree ADT (§2.3.1) Preorder and postorder traversals (§2.3.2) BinaryTree ADT (§2.3.3) Inorder traversal (§2.3.3) Euler Tour traversal (§2.3.3) Template method pattern Data structures for trees (§2.3.4)
Background image of page 1

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

View Full DocumentRight Arrow Icon
Trees 1/11/2006 10:04 PM 2 Trees 3 What is a Tree In computer science, a tree is an abstract model of a hierarchical structure A tree consists of nodes with a parent-child relation Applications: ± Organization charts ± File systems ± Programming environments Computers”R”Us Sales R&D Manufacturing Laptops Desktops US International Europe Asia Canada Trees 4 subtree Tree Terminology Root: node without parent (A) Internal node: node with at least one child (A, B, C, F) External node (a.k.a. leaf ): node without children (E, I, J, K, G, H, D) Ancestors of a node: parent, grandparent, grand-grandparent, etc. Depth of a node: number of ancestors Height of a tree: maximum depth of any node (3) Descendant of a node: child, grandchild, grand-grandchild, etc. A B D C G H E F I J K Subtree: tree consisting of a node and its descendants
Background image of page 2
Trees 1/11/2006 10:04 PM 3 Trees 5 Tree ADT We use positions to abstract nodes Generic methods: ± integer size () ± boolean isEmpty () ± objectIterator elements () ± positionIterator positions () Accessor methods: ± position root () ± position parent (p) ± positionIterator children (p) Query methods: ± boolean isInternal (p) ± boolean isExternal (p) ± boolean isRoot (p)
Background image of page 3

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

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

Page1 / 9

Trees-handouts-2-color - Trees 1/11/2006 10:04 PM Trees...

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

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