Book contents
- Frontmatter
- Contents
- Preface
- PART ONE FOUNDATIONS
- PART TWO DATA STRUCTURES
- 9 Abstract Data Types
- 10 Containers as Abstract Data Types
- 11 Stack and Queue
- 12 Application of Stack
- 13 Lists
- 14 Trees, Heaps, and Priority Queues
- 15 Search Trees
- 16 Hashing and Sets
- 17 Association and Dictionary
- 18 Sorting
- Appendix A Unified Modeling Language Notation
- Appendix B Complexity of Algorithms
- Appendix C Installing and Using Foundations Classes
- Index
15 - Search Trees
from PART TWO - DATA STRUCTURES
Published online by Cambridge University Press: 05 June 2012
- Frontmatter
- Contents
- Preface
- PART ONE FOUNDATIONS
- PART TWO DATA STRUCTURES
- 9 Abstract Data Types
- 10 Containers as Abstract Data Types
- 11 Stack and Queue
- 12 Application of Stack
- 13 Lists
- 14 Trees, Heaps, and Priority Queues
- 15 Search Trees
- 16 Hashing and Sets
- 17 Association and Dictionary
- 18 Sorting
- Appendix A Unified Modeling Language Notation
- Appendix B Complexity of Algorithms
- Appendix C Installing and Using Foundations Classes
- Index
Summary
Binary trees were introduced in the previous chapter. A binary tree holds the generic Object type that serves as a placeholder for any reference type. This combined with its nonlinear structure makes it suitable for representing a diversity of information.
This chapter focuses on a specialized but extremely important tree type – the search tree. Such a binary tree holds elements of type Comparable. That is, the elements stored in a search tree may be compared to one another by answering to the query compareTo. The goal of a search table is to provide efficient access to information while allowing the information to be output in an ordered sequence. The order of elements in a binary search tree is based on a comparable property of the elements themselves.
In Chapter 13 we examined the OrderedList as a concrete implementation of a SearchTable. Here we shall examine three concrete search tree classes, each providing an implementation of the interface SearchTable. These concrete classes are BinarySearchTree, AVLTree, and SplayTree. In addition, we shall investigate another interesting and recent implementation of SearchTable, given by class SkipList.
Review of Search Table Abstraction
Recall from Chapter 10 that a search table is a compact abstraction that extends Container and provides the commands add and remove in addition to the command makeEmpty in class Container. The queries contains, get, and iterator are provided by SearchTable in addition to the queries isEmpty and size inherited from Container.
- Type
- Chapter
- Information
- Fundamentals of OOP and Data Structures in Java , pp. 315 - 366Publisher: Cambridge University PressPrint publication year: 2000