7.1-tree_intro

7.1-tree_intro - Height of a tree T’s root • Level of a...

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

View Full Document Right Arrow Icon
CMPT 225 Introduction to Trees
Background image of page 1

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

View Full Document Right Arrow Icon
CMPT 225 What is a Tree – In Real World?
Background image of page 2
CMPT 225 What is a Tree – as a Data Structure? • Hierarchical • Sequential access • Definition: A set of zero (empty tree) or more “nodes” partitioned into a root “node” and subtrees (of the root) NOTE: “node” != class Node of our linked list
Background image of page 3

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

View Full Document Right Arrow Icon
CMPT 225 Tree Classification • Classify or name trees by potential maximum # of children (or subtrees) a node of the tree can have • Example:
Background image of page 4
CMPT 225 Terminology - 1 Root Node Edge Leaf See textbook @ pages __________ Parent Child Sibling Ancestor Descendant
Background image of page 5

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

View Full Document Right Arrow Icon
CMPT 225 Terminology - 2 • Path length: # of nodes in path. From node N 1 to another node N k , path length is K. • Height of a node N: Length of longest path from node N to a leaf. • Height of a tree T:
Background image of page 6
Background image of page 7

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

View Full Document Right Arrow Icon
Background image of page 8
Background image of page 9
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Height of a tree T’s root. • Level of a node N: If node N is the root of tree T, then node N is at level 1, otherwise level++ every time we reach root of subtree of node N. CMPT 225 Terminology - 3 • Empty tree • Full tree of height H: - All nodes at level < H have max # of children - Nodes @ level H have 0 children ( they are leaves ) • Complete tree of height H: is a tree that is full all the way down to level H-1 with level H filled in from left to right without any gap. CMPT 225 Terminology - 4 • Subtree: • Recursive Nature of Trees • Balanced tree: A N-ary tree in which all N subtrees of any nodes have height that differ by at most 1. CMPT 225 Bin-ary Tree • Definition: N-ary tree where N = 2 • Property: If binary tree T has height H then T has between H and 2 H-1 nodes...
View Full Document

{[ snackBarMessage ]}

Page1 / 9

7.1-tree_intro - Height of a tree T’s root • Level of a...

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

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