Front matter

foreword

preface

acknowledgments

about this book

about the author

1 introduction to algorithms

Binary search

Big O notation

2 selection sort

How memory works

Arrays and linked lists

Which is used more, arrays or linked lists?

Selection sort

Example code listing

3 recursion

Recursion

Base case and recursive case

The stack

4 quicksort

Divide and conquer

Quicksort

Big O notation revisited

5 hash tables

Hash functions

Use cases

Collisions

Performance

6 breadth-first search

Introduction to graphs

What is a graph?

Breadth-first search

Implementing the graph

Implementing the algorithm

7 trees

Your first tree

A space odyssey: Depth-first search

Binary trees

Huffman coding

8 balanced trees

A balancing act

Shorter trees are faster

AVL trees: A type of balanced tree

Splay trees

B-trees

9 Dijkstra’s algorithm

Working with Dijkstra’s algorithm

Terminology

Trading for a piano

Negative-weight edges

Implementation

10 greedy algorithms

The classroom scheduling problem

The knapsack problem

The set-covering problem

11 dynamic programming

The knapsack problem (revisited)

Knapsack problem FAQ

Longest common substring

12 k-nearest neighbors

Classifying oranges vs. grapefruit

Building a recommendations system

Regression

Introduction to machine learning

A high-level overview of training an ML model

13 where to go next

Linear regression

Inverted indexes

The Fourier transform

Parallel algorithms

map/reduce

Bloom filters and HyperLogLog

HTTPS and the Diffie–Hellman key exchange

Locality-sensitive hashing

Min heaps and priority queues

Linear programming

Epilogue

Appendix A. performance of AVL trees

Appendix B. NP-hard problems

Appendix C. answers to exercises

index