The.Algorithm.Design.Manual.Springer-Verlag.1998
The.Algorithm.Design.Manual.Springer-Verlag.1998 The.Algorithm.Design.Manual.Springer-Verlag.1998
Data Structures and Sorting Next: Fundamental Data Types Up: Techniques Previous: Implementation Challenges Data Structures and Sorting When things go right, changing a data structure in a slow program works the same way an organ transplant does in a sick patient. For several classes of abstract data types, such as containers, dictionaries, and priority queues, there exist many different but functionally equivalent data structures that implement the given data type. Changing the data structure does not change the correctness of the program, since we presumably replace a correct implementation with a different correct implementation. However, because the new implementation of the data type realizes different tradeoffs in the time to execute various operations, the total performance of an application can improve dramatically. Like a patient in need of a transplant, only one part might need to be replaced in order to fix the problem. It is obviously better to be born with a good heart than have to wait for a replacement. Similarly, the maximum benefit from good data structures results from designing your program around them in the first place. Still, it is important to build your programs so that alternative implementations can be tried. This involves separating the internals of the data structure (be it a tree, a hash table, or a sorted array) from its interface (operations like search, insert, delete). Such data abstraction is an important part of producing clean, readable, and modifiable programs. We will not dwell on such software engineering issues here, but such a design is critical if you are to experiment with the impact of different implementations on performance. In this chapter we will also discuss sorting, stressing how sorting can be applied to solve other problems more than the details of specific sorting algorithms. In this sense, sorting behaves more like a data structure than a problem in its own right. Sorting is also represented by a significant entry in the problem catalog; namely Section . The key take-home lessons of this chapter are: ● Building algorithms around data structures such as dictionaries and priority queues leads to both clean structure and good performance. ● Picking the wrong data structure for the job can be disastrous in terms of performance. Picking the very best data structure is often not as critical, for there are typically several choices that perform similarly. ● Sorting lies at the heart of many different algorithms. Sorting the data is one of the first things any algorithm designer should try in the quest for efficiency. ● Sorting can be used to illustrate most algorithm design paradigms. Data structure techniques, file:///E|/BOOK/BOOK/NODE22.HTM (1 of 2) [19/1/2003 1:27:43]
Data Structures and Sorting divide-and-conquer, randomization, and incremental construction all lead to popular sorting algorithms. ● Fundamental Data Types ❍ Containers ❍ Dictionaries ❍ Binary Search Trees ❍ Priority Queues ● Specialized Data Structures ● Sorting ● Applications of Sorting ● Approaches to Sorting ❍ Data Structures ❍ Incremental Insertion ❍ Divide and Conquer ❍ Randomization ❍ Bucketing Techniques ● War Story: Stripping Triangulations ● War Story: Mystery of the Pyramids ● War Story: String 'em Up ● Exercises Next: Fundamental Data Types Up: Techniques Previous: Implementation Challenges Algorithms Mon Jun 2 23:33:50 EDT 1997 file:///E|/BOOK/BOOK/NODE22.HTM (2 of 2) [19/1/2003 1:27:43]
- Page 1 and 2: The Algorithm Design Manual Next: P
- Page 3 and 4: Preface Next: Acknowledgments Up: T
- Page 5 and 6: Preface one stressing design over a
- Page 7 and 8: Acknowledgments Mon Jun 2 23:33:50
- Page 9 and 10: Contents Next: Techniques Up: The A
- Page 11 and 12: Contents ■ All-Pairs Shortest Pat
- Page 13 and 14: Contents ■ Graph Problems: Polyno
- Page 15 and 16: Contents ● About this document ..
- Page 17 and 18: The Algorithm Design Manual The Alg
- Page 19 and 20: Lecture Notes -- Analysis of Algori
- Page 21 and 22: Lecture Notes -- Analysis of Algori
- Page 23 and 24: The Stony Brook Algorithm Repositor
- Page 25 and 26: Techniques Next: Introduction to Al
- Page 27 and 28: Techniques Algorithms Mon Jun 2 23:
- Page 29: Introduction to Algorithms ● Reas
- Page 33 and 34: Breaking Problems Down ● Dynamic
- Page 35 and 36: Graph Algorithms The take-home less
- Page 37 and 38: Combinatorial Search and Heuristic
- Page 39 and 40: Intractable Problems and Approximat
- Page 41 and 42: How to Design Algorithms Next: Reso
- Page 43 and 44: How to Design Algorithms with a cou
- Page 45 and 46: How to Design Algorithms Next: Reso
- Page 47 and 48: A Catalog of Algorithmic Problems N
- Page 49 and 50: A Catalog of Algorithmic Problems
- Page 51 and 52: Algorithmic Resources Next: Softwar
- Page 53 and 54: References L. Adleman. Algorithmic
- Page 55 and 56: References AS89 Ata83 Ata84 problem
- Page 57 and 58: References BJL 91 A. Blum, T. Jiang
- Page 59 and 60: References BS81 BS86 BS93 BS96 BS97
- Page 61 and 62: References J. M. Chambers. Partial
- Page 63 and 64: References CT80 CT92 1971. G. Carpa
- Page 65 and 66: References K. Daniels and V. Milenk
- Page 67 and 68: References (FOCS), pages 60-69, 199
- Page 69 and 70: References FM71 M. Fischer and A. M
- Page 71 and 72: References History of Computing, 7:
- Page 73 and 74: References N. Gibbs, W. Poole, and
- Page 75 and 76: References Hof82 Hof89 Hol75 C. M.
- Page 77 and 78: References IK75 Ita78 O. Ibarra and
- Page 79 and 80: References Kir83 D. Kirkpatrick. Ef
Data Structures and Sorting<br />
Next: Fundamental Data Types Up: Techniques Previous: Implementation Challenges<br />
Data Structures and Sorting<br />
When things go right, changing a data structure in a slow program works the same way an organ<br />
transplant does in a sick patient. For several classes of abstract data types, such as containers,<br />
dictionaries, and priority queues, there exist many different but functionally equivalent data structures<br />
that implement the given data type. Changing the data structure does not change the correctness of the<br />
program, since we presumably replace a correct implementation with a different correct implementation.<br />
However, because the new implementation of the data type realizes different tradeoffs in the time to<br />
execute various operations, the total performance of an application can improve dramatically. Like a<br />
patient in need of a transplant, only one part might need to be replaced in order to fix the problem.<br />
It is obviously better to be born with a good heart than have to wait for a replacement. Similarly, the<br />
maximum benefit from good data structures results from designing your program around them in the first<br />
place. Still, it is important to build your programs so that alternative implementations can be tried. This<br />
involves separating the internals of the data structure (be it a tree, a hash table, or a sorted array) from its<br />
interface (operations like search, insert, delete). Such data abstraction is an important part of producing<br />
clean, readable, and modifiable programs. We will not dwell on such software engineering issues here,<br />
but such a design is critical if you are to experiment with the impact of different implementations on<br />
performance.<br />
In this chapter we will also discuss sorting, stressing how sorting can be applied to solve other problems<br />
more than the details of specific sorting algorithms. In this sense, sorting behaves more like a data<br />
structure than a problem in its own right. Sorting is also represented by a significant entry in the problem<br />
catalog; namely Section .<br />
<strong>The</strong> key take-home lessons of this chapter are:<br />
● Building algorithms around data structures such as dictionaries and priority queues leads to both<br />
clean structure and good performance.<br />
● Picking the wrong data structure for the job can be disastrous in terms of performance. Picking the<br />
very best data structure is often not as critical, for there are typically several choices that perform<br />
similarly.<br />
● Sorting lies at the heart of many different algorithms. Sorting the data is one of the first things any<br />
algorithm designer should try in the quest for efficiency.<br />
● Sorting can be used to illustrate most algorithm design paradigms. Data structure techniques,<br />
file:///E|/BOOK/BOOK/NODE22.HTM (1 of 2) [19/1/2003 1:27:43]