1 Introduction to algorithms

In this chapter

  • You get a foundation for the rest of the book.
  • You write your first search algorithm (binary search).
  • You learn how to talk about the running time of an algorithm (big O notation).

An algorithm is a set of instructions for accomplishing a task. Every piece of code could be called an algorithm, but this book covers the more interesting bits. I chose the algorithms in this book for inclusion because they’re fast, or they solve interesting problems, or both. Here are some highlights:

  • Chapter 1 talks about binary search and shows how an algorithm can speed up your code. In one example, the number of steps needed goes from 4 billion down to 32!

  • A GPS device uses graph algorithms (as you’ll learn in ...

Get Grokking Algorithms, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.