Book contents
- Frontmatter
- Contents
- Preface
- Introduction
- Part One Iterative Algorithms and Loop Invariants
- 1 Iterative Algorithms: Measures of Progress and Loop Invariants
- 2 Examples Using More-of-the-Input Loop Invariants
- 3 Abstract Data Types
- 4 Narrowing the Search Space: Binary Search
- 5 Iterative Sorting Algorithms
- 6 Euclid's GCD algorithm
- 7 The Loop Invariant for Lower Bounds
- Part Two Recursion
- Part Three Optimization Problems
- Part Four Appendix
- Part five Exercise Solutions
- Index
3 - Abstract Data Types
Published online by Cambridge University Press: 05 June 2012
- Frontmatter
- Contents
- Preface
- Introduction
- Part One Iterative Algorithms and Loop Invariants
- 1 Iterative Algorithms: Measures of Progress and Loop Invariants
- 2 Examples Using More-of-the-Input Loop Invariants
- 3 Abstract Data Types
- 4 Narrowing the Search Space: Binary Search
- 5 Iterative Sorting Algorithms
- 6 Euclid's GCD algorithm
- 7 The Loop Invariant for Lower Bounds
- Part Two Recursion
- Part Three Optimization Problems
- Part Four Appendix
- Part five Exercise Solutions
- Index
Summary
Abstract data types (ADTs) provide both a language for talking about and tools for operating on complex data structures. Each is defined by the types of objects that it can store and the operations that can be performed. Unlike a function that takes an input and produces an output, an ADT is more dynamic, periodically receiving information and commands to which it must react in a way that reflects its history. In an object-oriented language, these are implemented with objects, each of which has its own internal variables and operations. A user of an ADT has no access to its internal structure except through the operations provided. This is referred to as information hiding and provides a clean boundary between the user and the ADT. One person can use the ADT to develop other algorithms without being concerned with how it is implemented or worrying about accidentally messing up the data structure. Another can implement and modify the ADT without knowing how it is used or worrying about unexpected effects on the rest of the code. A general purpose ADT—not just the code, but also the understanding and the mathematical theory—can be reused in many applications. Having a limited set of operations guides the implementer to use techniques that are efficient for these operations yet may be slow for the operations excluded. Conversely, using an ADT such as a stack in your algorithm automatically tells someone attempting to understand your algorithm a great deal about the purpose of this data structure.
- Type
- Chapter
- Information
- How to Think About Algorithms , pp. 43 - 59Publisher: Cambridge University PressPrint publication year: 2008