4. Algorithms and Data Structures
Overview.In this chapter we describe and implement some of the most important algorithms and data structures in use on computers today. (For a more in-depth treatment, we recommend the companion textbook Algorithms, 4th Edition.) We begin by considering a powerful framework for measuring and analyzing the efficiency of our programs. This enables us to compare algorithms and accurately predict performance. Next, we consider several novel algorithms for the classic problem of sorting. Then, we build the most important higher level data structures, including stacks, queues, and symbol tables.
- 4.1 Performance outlines a scientific method and powerful theory for understanding the performance and resource consumption of the program that we write.
- 4.2 Sorting and Searching describes two classical algorithms - mergesort and binary search - along with several applications where their efficiency plays a critical role.
- 4.3 Stacks and Queues introduces two closely related data structures for manipulating arbitrary large collections of data.
- 4.4 Symbol Tables considers a quintessential data structure known as the symbol table for storing information, and an efficient implementation known as the binary search tree.
- 4.5 Small World Phenomenon presents a case study to investigate the small world phenomenon - the principle that we are all linked by short chains of acquaintances.
Java programs in this chapter.Below is a list of Java programs in this chapter. Click on the program name to access the Java code; click on the reference number for a brief description; read the textbook for a full discussion.
REF PROGRAM DESCRIPTION 4.1.2 DoublingTest.java validating a doubling hypothesis 4.2.2 Gaussian.java bisection search (function inversion) 4.2.4 Insertion.java insertion sort 4.2.6 Merge.java mergesort 4.2.8 LRS.java longest repeated substring 4.3.2 LinkedStackOfStrings.java stack of strings (linked list) 4.3.4 Stack.java stack data type 4.3.6 Queue.java queue data type 4.3.8 LoadBalance.java load balancing simulation 4.4.2 Index.java indexing 4.4.4 DeDup.java dedup filter 4.5.2 IndexGraph.java using a graph to invert an index 4.5.4 PathFinder.java shortest-paths implementation