vii.
Introduction
Written by Jonathan Sande
How to Read This Book
The chapters in this book build on each other, so most readers will want to progress through the content in a linear manner.
Most chapters begin by introducing a data structure or algorithm with examples and illustrations. This is to help you gain a high-level conceptual understanding before diving into the code. Adventurous readers may wish to pause at this point and try to implement the data structure or algorithm on their own before looking at how the chapter does it. Even if you’re not successful, attempting to solve the problem will almost certainly cause you to have a deeper understanding of the requirements. An alternative strategy is to work through each chapter directly. Then, when finished, delete all of the code you copied and try to reproduce the data structure or algorithm based on your understanding.
You’ll find challenge problems at the end of many chapters. These will help to test your understanding of what you learned. Try to solve the challenges yourself before looking at the answers. When you need to look, you can find the solutions at the end of the book or in the supplemental downloadable materials that accompany the book.
This book is split into five main content sections:
Section I: Introduction
The chapters in this short but essential section will provide the foundation and motivation for the study of data structures and algorithms. You’ll also get a quick rundown of the Dart core library, which you’ll use as a basis for creating your own data structures and algorithms.
Section II: Elementary Data Structures
This section looks at a few important data structures that are not found in the dart:core
library but form the basis of more advanced algorithms covered in future sections. All of them are collections optimized for and enforcing a particular access pattern.
The dart:collection
library, which comes with Dart, does contain LinkedList
and Queue
classes. However, learning to build these data structures yourself is why you’re reading this book, isn’t it?
Even with just these basics, you‘ll begin to start thinking “algorithmically” and seeing the connection between data structures and algorithms.
Section III: Trees
Trees are another way to organize information, introducing the concept of children and parents. You’ll take a look at the most common tree types and see how they can be used to solve specific computational problems. Trees are a handy way to organize information when performance is critical. Having them in your tool belt will undoubtedly prove to be useful throughout your career.
Section IV: Sorting Algorithms
Putting lists in order is a classical computational problem. Although you may never need to write your own sorting algorithm, studying this topic has many benefits. This section will teach you about stability, best- and worst-case times, and the all-important technique of divide and conquer.
Studying sorting may seem a bit academic and disconnected from the “real world” of app development, but understanding the tradeoffs for these simple cases will lead you to a better understanding of how to analyze any algorithm.
Section V: Graphs
Graphs are an instrumental data structure that can model a wide range of things: webpages on the internet, the migration patterns of birds, even protons in the nucleus of an atom. This section gets you thinking deeply (and broadly) about using graphs and graph algorithms to solve real-world problems.