Presentation is loading. Please wait.

Presentation is loading. Please wait.

Tree - in “math speak” An ________ graph is a set of vertices/nodes and a set of edges, each edge connects two vertices. Any undirected graph in which.

Similar presentations


Presentation on theme: "Tree - in “math speak” An ________ graph is a set of vertices/nodes and a set of edges, each edge connects two vertices. Any undirected graph in which."— Presentation transcript:

1 Tree - in “math speak” An ________ graph is a set of vertices/nodes and a set of edges, each edge connects two vertices. Any undirected graph in which every two vertices are connected by exactly one path (sequence of edges & associated vertices) is a ______.

2 Tree - more properties A tree is a minimally connected graph (i.e., all vertices are connected by paths, but removing any edge disconnects) A tree is a connected graph with one less edge than vertex. A tree is a maximally acyclic graph (i.e., it contains no cycles, but adding another edge creates one or more cycles)

3 Changing Tree Geometry This is a typical tree to a computer scientist. properties: ______ _______ Vertices are often called _____.

4 The extreme “ends” of a tree A ____is a node at the extreme end of a path from the root (i.e., there are no edges to allow the path to continue). Identify the leaves in the following trees.

5 Trees can be taller/shorter A _______of a tree is the number of nodes in its longest path from root to leaf.

6 Directed Trees Tree edges are directed from the root outward. A ______node shares an edge with every ______. The parent is “closer to” the root. Def’n: rooted (directed) tree Every node, except the root, has exactly one parent. Def’n: rooted (directed) tree Every node, except the root, has exactly one parent.

7 The tree’s “extended family” If n 1 is the parent of n 2, then n 1 is n 2 ’s ancestor. ancestor If n 1 is the parent of n a and n a is an ancestor of n 2, then n 1 is n 2 ’s ancestor. If n 1 is the ancestor of n 2, then n 2 is n 1 ’s descendant. descendant The level of a node is the number of edges in its path to the root. level

8 Subtrees Any node of a tree, together with all of its descendants and associated edges, forms a subtree. subtree Example: the subtree rooted at F

9 Expression Trees - An Application An expression tree is a tree in which a node contains either an operand or operator and each subtree represents a subexpression of the whole. Example: (1 + 2) * (3 - 4) / -(5 * 6)

10 Decision Trees - Another Application A decision tree maintains yes/no questions in each non-leaf node, and each left subtree is for “no” while the right subtree is for “yes”. Example


Download ppt "Tree - in “math speak” An ________ graph is a set of vertices/nodes and a set of edges, each edge connects two vertices. Any undirected graph in which."

Similar presentations


Ads by Google