SlideServe
Menu
Préférences
© SlideServe · v2026

Understanding Trees: Properties, Structures, and Traversal Methods in Graph Theory

turi avatar
47 diapositives · 640 Views · Sep 04, 2014

This chapter provides a comprehensive overview of trees in graph theory, outlining essential concepts such as undirected trees, rooted trees, and m-ary trees. Key definitions and theorems, including properties of vertices, edges, and paths, are explored, along with practical applications such as binary search trees and tree traversal techniques (inorder, preorder, postorder). The roles of parent, child, siblings, leaves, and ancestors are defined to enhance understanding. Additionally, spanning trees and search algorithms are discussed in the context of efficient graph traversal and tree construction.

Understanding Trees: Properties, Structures, and Traversal Methods in Graph Theory - slide 1
01 / 47Understanding Trees: Properties, Structures, and Traversal Methods in Graph Theory
1 / 17

Télécharger la présentation

Understanding Trees: Properties, Structures, and Traversal Methods in Graph Theory
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. Trees Chapter 9

  2. Tree • graph • connected • undirected • no simple circuits (acyclic) • no multiple edges • no loops

  3. Sample Trees? Tree Tree Not Not

  4. Theorem 1 • An undirected graph is a tree iff • A simple path exists in a tree • between any two vertices

  5. Root • A particular tree vertex • from which we assign a direction to each edge • Each edge is directed away from the root

  6. Rooted tree • A tree with a designated root • A directed graph • Direction of all edges is away from root

  7. Parent • In a rooted tree, • a parent of vertex v is • the unique vertex u • such that there is a directed edge from u to v

  8. Child • The vertex v • to which a directed edge exists • from parent u in a rooted tree

  9. Siblings • vertices with the same parent

  10. Leaf • a vertex of a tree that has no children

  11. Ancestors of node A • nodes located on the path • from A to the root

  12. Descendants of node A • nodes located on the path • from A to a leaf node

  13. Internal vertices • Vertices with children

  14. Sub-tree • a tree • contained in a larger tree • whose root may be a child node • in the larger tree

  15. m-ary tree • a rooted tree • with no more than m children per vertex

  16. Full m-ary tree • a rooted tree • whose every internal vertex • has exactly m children

  17. Theorem 2 • A tree with n vertices has n - 1 edges. 7 vertices 6 edges

  18. Theorem 3 • A full m-ary tree • with i internal vertices • contains n = mi + 1 vertices. m = 2 i = 7 15 vertices

  19. Tree Height • height (level) of a node • the length of the path from the root to a node • height of a tree • the length of the longest path in a tree

  20. The maximum number of nodes at any level is mh • h is height of a node at that level of the tree 212223

  21. The minimum number of nodes • of a tree of height h is • h+1

  22. The maximum number of nodes • in a tree of height h is • m(h+1) -1 • 2(3+1) - 1

  23. Balanced tree • A rooted m-ary tree of height h • is called balanced • if all leaves are at level h or h - 1 YES NO YES

  24. If an m-ary tree of height h • has l leaves, • and the tree is full and balanced, • h = ceil(log m l) • h = ceil (log28) • h = 3 What does this imply about access speed if a tree is used as a data structure?

  25. Applications of Trees 8.2

  26. Binary search tree • A binary tree where key value in any node is • greater than key of its left child • and any of its children • (the nodes in the left subtree) • less than key of its right child • and any of its children • (the nodes in the right subtree) • http://math.nemcc.edu/bst/

  27. Binary Search Tree Example

  28. Form a BST with the words Mathematics, Physics, Geography, Zoology, Meteorology, Geology, Psychology, Chemistry

  29. NOTE:Input order determines a tree's shape.Tree Animation

  30. Tree Traversal 8.3

  31. Inorder Tree Traversal • process Left subtree inorder • Visit a node (or process node) • Process Right subtree inorder • Processes BST vertices in ascending sequence • http://nova.umuc.edu/~jarc/idsv/lesson1.html

  32. Inorder Traversal Example LVR Arps, Dietz, Egofske, Fairchild, Garth, Huston, Keith Magillicuddy, Nathan, Perkins, Seliger, Talbot, Underwood,Verkins, Zarda

  33. Preorder Tree Traversal • allows quickest access to the whole tree • VISIT a node • process LEFT subtree in preorder • process RIGHT subtree in preorder

  34. Preorder Traversal Example VLR Magillicuddy, Fairchild, Dietz, Arps, Egofske, Huston, Garth, Keith, Talbot, Perkins, Nathan, Selinger, Verkins, Underwood, Zarda

  35. Postorder Tree Traversal • good for deletion of nodes; postfix notation • process LEFT subtree in postorder • process RIGHT subtree in postorder • VISIT a node

  36. Postorder Traversal Example LRV Arps, Egofske, Dietz, Garth, Keith, Huston, Fairchild, Nathan, Selinger, Perkinds, Underwood, Zarda, Verkins, Talbot, Magillicuddy

  37. Expression Tree • An ordered rooted tree • associates operands & operators in a uniform way +

  38. Give Pre, In, Postorder • PreOrder: • - + + * 6 2 7 * 8 3 / 6 7 • InOrder: • 6 * 2 + 7 + 8 * 3 - 6 / 7 • PostOrder: • 6 2 * 7 + 8 3 * + 6 7 / - +

  39. Spanning Trees 9.4

  40. Spanning Subgraph • A spanning subgraph of G is • G’ = (V, E’) • where E’ is a subset of E • Note every vertex of G is included

  41. Spanning Tree • A spanning subgraph that is a tree • connected • acyclic • See p. 581-2

  42. Depth First Search • A procedure for constructing a spanning tree • by adding edges that form a path until this is not possible • then moving back up the tree • until a vertex is found where a new path can be formed • http://www.cs.sunysb.edu/~skiena/combinatorica/animations/search.html

  43. Breadth First Search • A procedure for constructing a spanning tree • that successively adds all edges incident to the last set of edges added • unless a simple circuit isformed • http://www.cs.duke.edu/~wcp/DFSanim.html • http://152.3.140.5/~wcp/DFSanim.html

  44. Perform DFS, BFS search DFS: a, b, c, d, e, f, g BFS: a b c g d e f

  45. Perform DFS, BFS search DFS: a, b, c, d, e, f BFS: a b d e c f

  46. Minimum Spanning Tree • A connected weighted graph • is a spanning tree that has • the smallest possible sum of weights of its edges. • http://study.haifa.ac.il/~hvaiderm/sem3.html