Chapter20

# Chapter20 - CHAPTER 20 Binary Trees Chapter Objectives This...

This preview shows pages 1–3. Sign up to view the full content.

Chapter Objectives This chapter discusses: Dynamic data structure concepts The nature of a binary tree and its derivative—the binary search tree (BST) How to process binary trees in general Those operations defined for general data collections that are relevant to binary trees or BSTs Introduction We move to a slightly more complex dynamic data structure—the binary tree. Where each node of a linked list contains only one child node, a binary tree has two child nodes, normally referred to as the left and right nodes, as shown in Figure 20.1. Within this structure, we need to consider two cases: a binary tree, where the data in the tree exhibit no apparent organization, and a binary search tree, where the data are organized for efficient searching. Binary Trees CHAPTER 20 20.1 Dynamic Data Structure Concepts 20.1.1 Graphs 20.1.2 Paths 20.1.3 Directed Acyclic Graphs 20.1.4 Roots 20.1.5 Leaves 20.1.6 N-ary Trees 20.1.7 Binary Trees 20.1.8 Binary Search Trees 20.2 Processing Binary Trees 20.3 Processing Binary Search Trees 20.4 Traversing a Binary Tree 20.4.1 Two Depth-First Traversals 20.4.2 Breadth-First Traversal 20.5 Building a Binary Search Tree 20.6 Mapping a Binary Tree 20.7 Deleting Nodes from a Binary Search Tree 20.8 Folding a Binary Tree 20.9 Searching Binary Trees 20.9.1 Breadth-First Search 20.9.2 Depth-First Search 20.9.3 Searching a Binary Search Tree 20.9.4 Testing Binary Search Tree Functionality 20.10 Combining Complex Operations 529 inOrderTree preOrderString insertInOrder BFFind DFFind char count display BinaryTree root left BTNode right data left BTNode right data left BTNode right data left BTNode right data left BTNode right data left BTNode right data Figure 20.1 Structure of a binary tree

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

View Full Document
530 Chapter 20 Binary Trees 20.1 Dynamic Data Structure Concepts 20.1.1 Graphs The most general form of dynamic data structure is a graph—an arbitrary collection of nodes connected by edges. A street map is a good example of a graph, where the intersections are the nodes and the streets are the edges. The edges may be directional to indicate that the graph can be traversed at that point in only one direction (like a one-way street). The edges may also have a value associated with them to indicate, for example, the cost of traversing that edge. For a street map, this could be either the distance or, perhaps in a more sophisticated system, the travel time—a function of the distance, the speed limit, and the traffic congestion. Graphs are not required to be completely connected, and they can obviously contain cycles—closed loops in which the unwary algorithm could get trapped. Graphs also have no obvious starting and stopping points. 20.1.2 Paths
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 11/21/2011 for the course CS 1371 taught by Professor Stallworth during the Fall '08 term at Georgia Tech.

### Page1 / 20

Chapter20 - CHAPTER 20 Binary Trees Chapter Objectives This...

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

View Full Document
Ask a homework question - tutors are online