Presentation is loading. Please wait.

Presentation is loading. Please wait.

Tree traversal from Introduction to Trees Chapter 6 Objectives

Similar presentations


Presentation on theme: "Tree traversal from Introduction to Trees Chapter 6 Objectives"— Presentation transcript:

1 Tree traversal from Introduction to Trees Chapter 6 Objectives
Upon completion you will be able to: Process trees using depth-first and breadth-first traversals Parse expressions using a binary tree Data Structures: A Pseudocode Approach with C

2 Binary Trees A binary tree is an ordered tree in which no node can have more than two subtrees; the maximum outdegree for a node is two. In other words, a node can have zero, one, or two subtrees. These subtrees are designated as the left subtree and the right subtree. Data Structures: A Pseudocode Approach with C

3 Data Structures: A Pseudocode Approach with C

4 A null tree is a tree with no nodes
Data Structures: A Pseudocode Approach with C

5 Complete binary trees A complete tree has the maximum number of entries for its height. The maximum number is reached when the last level is full. A tree is considered nearly complete if it has the minimum height for its nodes and all nodes in the last level are found on the left Data Structures: A Pseudocode Approach with C

6 Data Structures: A Pseudocode Approach with C

7 Binary Tree Traversal A binary tree traversal requires that each node of the tree be processed (to be visited - for example: printed) once and only once in a predetermined sequence. In the depth-first traversal processing process along a path from the root through one child to the most distant descendant of that first child before processing a second child. Data Structures: A Pseudocode Approach with C

8 Data Structures: A Pseudocode Approach with C

9 Data Structures: A Pseudocode Approach with C

10 Data Structures: A Pseudocode Approach with C

11 Data Structures: A Pseudocode Approach with C

12 Data Structures: A Pseudocode Approach with C

13 Data Structures: A Pseudocode Approach with C

14 Data Structures: A Pseudocode Approach with C

15 Data Structures: A Pseudocode Approach with C

16 Data Structures: A Pseudocode Approach with C

17 Data Structures: A Pseudocode Approach with C

18 Data Structures: A Pseudocode Approach with C

19 Data Structures: A Pseudocode Approach with C

20 Data Structures: A Pseudocode Approach with C

21 Data Structures: A Pseudocode Approach with C

22 Data Structures: A Pseudocode Approach with C

23 Data Structures: A Pseudocode Approach with C

24 Data Structures: A Pseudocode Approach with C


Download ppt "Tree traversal from Introduction to Trees Chapter 6 Objectives"

Similar presentations


Ads by Google