# Content

## 1. Introduction to Algorithms

* [Introduction](https://grokking.realtemirov.uz/1.-introduction-to-algorithms/1.-introduction)
  * [What you'll learn about performance](https://grokking.realtemirov.uz/1.-introduction-to-algorithms/1.-introduction#what-youll-learn-about-performance)
  * [What you'll learn about solving problems](https://github.com/realtemirov/grokking-algorithms/blob/main/1.%20Introduction%20to%20Algorithms/01%20Introduction.md#what-youll-learn-about-solving-problems)
* [Binary search](https://grokking.realtemirov.uz/1.-introduction-to-algorithms/2.-binary-search)
  * [A better way to search](https://grokking.realtemirov.uz/1.-introduction-to-algorithms/2.-binary-search#a-better-way-to-search)
  * [Running time](https://grokking.realtemirov.uz/1.-introduction-to-algorithms/2.-binary-search#running-time)
* [Big O notation](https://grokking.realtemirov.uz/1.-introduction-to-algorithms/3.-big-o-notation)
  * [Algorithm running times grow at different rates](https://grokking.realtemirov.uz/1.-introduction-to-algorithms/3.-big-o-notation#algorithm-running-times-grow-at-different-rates)
  * [Visualizing different Big O run times](https://grokking.realtemirov.uz/1.-introduction-to-algorithms/3.-big-o-notation#visualizing-different-big-o-run-times)
  * [Big O establishes a worst-case run time](https://grokking.realtemirov.uz/1.-introduction-to-algorithms/3.-big-o-notation#big-o-establishes-a-worst-case-run-time)
  * [Some common Big O run times](https://grokking.realtemirov.uz/1.-introduction-to-algorithms/3.-big-o-notation#some-common-big-o-run-times)
  * [The traveling salesperson](https://grokking.realtemirov.uz/1.-introduction-to-algorithms/3.-big-o-notation#the-traveling-salesperson)
* [Recap](https://grokking.realtemirov.uz/1.-introduction-to-algorithms/4.-recap)

## 2. Selection sort

* [How memory works](https://grokking.realtemirov.uz/2.-selection-sort/1.-how-memory-works)
* [Arrays and linked lists](https://grokking.realtemirov.uz/2.-selection-sort/2.-arrays-and-linked-lists)
  * [Linked lists](https://grokking.realtemirov.uz/2.-selection-sort/2.-arrays-and-linked-lists#linked-lists)
  * [Arrays](https://grokking.realtemirov.uz/2.-selection-sort/2.-arrays-and-linked-lists#arrays)
  * [Terminology](https://grokking.realtemirov.uz/2.-selection-sort/2.-arrays-and-linked-lists#terminology)
  * [Inserting into the middle of a list](https://grokking.realtemirov.uz/2.-selection-sort/2.-arrays-and-linked-lists#inserting-into-the-middle-of-a-list)
  * [Deletions](https://grokking.realtemirov.uz/2.-selection-sort/2.-arrays-and-linked-lists#deletions)
* [Selection sort](https://grokking.realtemirov.uz/2.-selection-sort/3.-selection-sort)
* [Recap](https://grokking.realtemirov.uz/2.-selection-sort/4.-recap)

## 3. Recursion

* [Recursion](https://grokking.realtemirov.uz/3.-recursion/1.-recursion)
* [Base case and recursive case](https://grokking.realtemirov.uz/3.-recursion/2.-base-case-and-recursive-case)
* [The stack](https://grokking.realtemirov.uz/3.-recursion/3.-the-stack)
  * [The call stack](https://grokking.realtemirov.uz/3.-recursion/3.-the-stack#the-call-stack)
  * [The call stack with recursion](https://grokking.realtemirov.uz/3.-recursion/3.-the-stack#the-call-stack-with-recursion)
* [Recap](https://grokking.realtemirov.uz/3.-recursion/4.-recap)

## 4. Quicksort

* [Divide & conquer](https://grokking.realtemirov.uz/4.-quicksort/1.-divide-and-conquer)
* [Quicksort](https://grokking.realtemirov.uz/4.-quicksort/2.-quicksort)
* [Big O notation revisited](https://grokking.realtemirov.uz/4.-quicksort/3.-big-o-notation-revisited)
  * [Merge sort vs. quicksort](https://grokking.realtemirov.uz/4.-quicksort/3.-big-o-notation-revisited#merge-sort-vs.-quicksort)
  * [Average case vs. worst case](https://grokking.realtemirov.uz/4.-quicksort/3.-big-o-notation-revisited#average-case-vs.-worst-case)
* [Recap](https://grokking.realtemirov.uz/4.-quicksort/4.-recap)

## 5. Hash tables

* [Hash functions](https://grokking.realtemirov.uz/5.-hash-tables/1.-hash-functions)
* [Use cases](https://grokking.realtemirov.uz/5.-hash-tables/2.-use-cases)
  * [Using hash tables for lookups](https://grokking.realtemirov.uz/5.-hash-tables/2.-use-cases#using-hash-tables-for-lookups)
  * [Preventing duplicate entries](https://grokking.realtemirov.uz/5.-hash-tables/2.-use-cases#preventing-duplicate-entries)
  * [Using hash tables as a cache](https://grokking.realtemirov.uz/5.-hash-tables/2.-use-cases#using-hash-tables-as-a-cache)
  * [Recap](https://grokking.realtemirov.uz/5.-hash-tables/2.-use-cases#recap)
* [Collisions](https://grokking.realtemirov.uz/5.-hash-tables/3.-collisions)
* [Performance](https://grokking.realtemirov.uz/5.-hash-tables/4.-performance)
  * [Load factor](https://grokking.realtemirov.uz/5.-hash-tables/4.-performance#load-factor)
  * [A good hash function](https://grokking.realtemirov.uz/5.-hash-tables/4.-performance#a-good-hash-function)
* [Recap](https://grokking.realtemirov.uz/5.-hash-tables/5.-recap)

## 6. Breadth-first search

* [Introduction to graph](https://grokking.realtemirov.uz/6.-breadth-first-search/1.-introduction-to-graph)
* [What is a graph](https://grokking.realtemirov.uz/6.-breadth-first-search/2.-what-is-a-graph)
* [Breadth-first search](https://grokking.realtemirov.uz/6.-breadth-first-search/3.-breadth-first-search)
  * [Finding the shortes path](https://grokking.realtemirov.uz/6.-breadth-first-search/3.-breadth-first-search#finding-the-shortes-path)
  * [Queues](https://grokking.realtemirov.uz/6.-breadth-first-search/3.-breadth-first-search#queues)
* [Implementing the graph](https://grokking.realtemirov.uz/6.-breadth-first-search/4.-implementing-the-graph)
* [Implementing the algorithm](https://grokking.realtemirov.uz/6.-breadth-first-search/5.-implementing-the-algorithm)
  * [Running time](https://grokking.realtemirov.uz/6.-breadth-first-search/5.-implementing-the-algorithm#running-time)
* [Recap](https://grokking.realtemirov.uz/6.-breadth-first-search/6.-recap)

## 7. Dijkstra's algorithm

* [Working with Dijkstra's algorithm](https://grokking.realtemirov.uz/7.-dijkstras-algorithm/1.-working-with-dijkstras-algorithm)
* [Terminology](https://grokking.realtemirov.uz/7.-dijkstras-algorithm/2.-terminology)
* [Trading for a piano](https://grokking.realtemirov.uz/7.-dijkstras-algorithm/3.-trading-for-a-piano)
* [Negative-weight edges](https://grokking.realtemirov.uz/7.-dijkstras-algorithm/4.-negative-weight-edges)
* [Implementation](https://grokking.realtemirov.uz/7.-dijkstras-algorithm/5.-implementation)
* [Recap](https://grokking.realtemirov.uz/7.-dijkstras-algorithm/6.-recap)

## 8. Greedy Algorithms

* [The classroom scheduling problem](https://grokking.realtemirov.uz/8.-greedy-algorithms/1.-the-classroom-scheduling-problem)
* [The knapsack problem](https://grokking.realtemirov.uz/8.-greedy-algorithms/2.-the-knapsack-problem)
* [The set-covering problem](https://grokking.realtemirov.uz/8.-greedy-algorithms/3.-the-set-covering-problem)
  * [Approximation algorithms](https://grokking.realtemirov.uz/8.-greedy-algorithms/3.-the-set-covering-problem#approximation-algorithms)
* [NP-complete problems](https://grokking.realtemirov.uz/8.-greedy-algorithms/4.-np-complete-problems)
* [Traveling salesperson, step by step](https://grokking.realtemirov.uz/8.-greedy-algorithms/5.-traveling-salesperson-step-by-step)
  * [How do you tell if a problem is NP-complete?](https://grokking.realtemirov.uz/8.-greedy-algorithms/5.-traveling-salesperson-step-by-step#how-do-you-tell-if-a-problem-is-np-complete)
* [Recap](https://grokking.realtemirov.uz/8.-greedy-algorithms/6.-recap)

## 9. Dynamic programming

* [The knapsack problem](https://grokking.realtemirov.uz/9.-dynamic-programming/1.-the-knapsack-problem)
  * [The simple solution](https://grokking.realtemirov.uz/9.-dynamic-programming/1.-the-knapsack-problem#the-simple-solution)
  * [Dynamic programming](https://grokking.realtemirov.uz/9.-dynamic-programming/1.-the-knapsack-problem#dynamic-programming)
* [Knapsack problem FAQ](https://grokking.realtemirov.uz/9.-dynamic-programming/2.-knapsack-problem-faq)
  * [What happens if you add an item?](https://grokking.realtemirov.uz/9.-dynamic-programming/2.-knapsack-problem-faq#what-happens-if-you-add-an-item)
  * [What happens if you change the order of the rows?](https://grokking.realtemirov.uz/9.-dynamic-programming/2.-knapsack-problem-faq#what-happens-if-you-change-the-order-of-the-rows)
  * [Can you fill in the grid column-wise instead of row-wise?](https://grokking.realtemirov.uz/9.-dynamic-programming/2.-knapsack-problem-faq#can-you-fill-in-the-grid-column-wise-instead-of-row-wise)
  * [What happens if you add a smaller item?](https://grokking.realtemirov.uz/9.-dynamic-programming/2.-knapsack-problem-faq#what-happens-if-you-add-a-smaller-item)
  * [Can you steal fractions of an item?](https://grokking.realtemirov.uz/9.-dynamic-programming/2.-knapsack-problem-faq#can-you-steal-fractions-of-an-item)
  * [Optimizing your travel itinerary](https://grokking.realtemirov.uz/9.-dynamic-programming/2.-knapsack-problem-faq#optimizing-your-travel-itinerary)
  * [Handling items that depend on each other](https://grokking.realtemirov.uz/9.-dynamic-programming/2.-knapsack-problem-faq#handling-items-that-depend-on-each-other)
  * [Is it possible that the solution will require more than two sub-knapsacks?](https://grokking.realtemirov.uz/9.-dynamic-programming/2.-knapsack-problem-faq#is-it-possible-that-the-solution-will-require-more-than-two-sub-knapsacks)
  * [Is it possible that the best solution doesn't fill the knapsack completely?](https://grokking.realtemirov.uz/9.-dynamic-programming/2.-knapsack-problem-faq#is-it-possible-that-the-best-solution-doesnt-fill-the-knapsack-completely)
* [Longest common substring](https://grokking.realtemirov.uz/9.-dynamic-programming/3.-longest-common-substring)
  * [Making the grid](https://grokking.realtemirov.uz/9.-dynamic-programming/3.-longest-common-substring#making-the-grid)
  * [Filling in the grid](https://grokking.realtemirov.uz/9.-dynamic-programming/3.-longest-common-substring#filling-in-the-grid)
  * [The solution](https://grokking.realtemirov.uz/9.-dynamic-programming/3.-longest-common-substring#the-solution)
  * [Longest common subsequence](https://grokking.realtemirov.uz/9.-dynamic-programming/3.-longest-common-substring#longest-common-subsequence)
  * [Longest common subsequence—solution](https://grokking.realtemirov.uz/9.-dynamic-programming/3.-longest-common-substring#longest-common-subsequencesolution)
* [Recap](https://grokking.realtemirov.uz/12.-answers-to-exercises/chapter-2)

## 10. K-nearest neighbors

* [Classifying oranges vs. grapefruit](https://grokking.realtemirov.uz/10.-k-nearest-neighbors/1.-classifying-oranges-vs.-grapefruit)
* [Building a recommendations system](https://grokking.realtemirov.uz/10.-k-nearest-neighbors/2.-building-a-recommendations-system)
  * [Feature extraction](https://grokking.realtemirov.uz/10.-k-nearest-neighbors/2.-building-a-recommendations-system#feature-extraction)
  * [Regression](https://grokking.realtemirov.uz/10.-k-nearest-neighbors/2.-building-a-recommendations-system#regression)
  * [Picking good features](https://grokking.realtemirov.uz/10.-k-nearest-neighbors/2.-building-a-recommendations-system#picking-good-features)
* [Introduction to machine learning](https://grokking.realtemirov.uz/10.-k-nearest-neighbors/3.-introduction-to-machine-learning)
  * [OCR](https://grokking.realtemirov.uz/10.-k-nearest-neighbors/3.-introduction-to-machine-learning#ocr)
  * [Building a spam filter](https://grokking.realtemirov.uz/10.-k-nearest-neighbors/3.-introduction-to-machine-learning#building-a-spam-filter)
  * [Predicting the stock market](https://grokking.realtemirov.uz/10.-k-nearest-neighbors/3.-introduction-to-machine-learning#predicting-the-stock-market)
* [Recap](https://grokking.realtemirov.uz/10.-k-nearest-neighbors/4.-recap)

## 11. Where to go next

* [Trees](https://grokking.realtemirov.uz/11.-where-to-go-next/1.-trees)
* [Inverted indexes](https://grokking.realtemirov.uz/11.-where-to-go-next/2.-inverted-indexes)
* [The Fourier transform](https://grokking.realtemirov.uz/11.-where-to-go-next/3.-the-fourier-transform)
* [Parallel algorithms](https://grokking.realtemirov.uz/11.-where-to-go-next/4.-parallel-algorithms)
* [MapReduce](https://grokking.realtemirov.uz/11.-where-to-go-next/5.-mapreduce)
  * [Why are distributed algorithms useful?](https://grokking.realtemirov.uz/11.-where-to-go-next/5.-mapreduce#why-are-distributed-algorithms-useful)
  * [The map function](https://grokking.realtemirov.uz/11.-where-to-go-next/5.-mapreduce#the-map-function)
  * [The reduce function](https://grokking.realtemirov.uz/11.-where-to-go-next/5.-mapreduce#the-reduce-function)
* [Bloom filters and HyperLogLog](https://grokking.realtemirov.uz/11.-where-to-go-next/6.-bloom-filters-and-hyperloglog)
  * [Bloom filters](https://grokking.realtemirov.uz/11.-where-to-go-next/6.-bloom-filters-and-hyperloglog#bloom-filters)
  * [HyperLogLog](https://grokking.realtemirov.uz/11.-where-to-go-next/6.-bloom-filters-and-hyperloglog#hyperloglog)
* [The SHA algorithms](https://grokking.realtemirov.uz/11.-where-to-go-next/7.-the-sha-algorithms)
  * [Comparing files](https://grokking.realtemirov.uz/11.-where-to-go-next/7.-the-sha-algorithms#comparing-files)
  * [Checking passwords](https://grokking.realtemirov.uz/11.-where-to-go-next/7.-the-sha-algorithms#checking-passwords)
* [Locality-sensitive hashing](https://grokking.realtemirov.uz/11.-where-to-go-next/8.-locality-sensitive-hashing)
* [Diffie-Hellman key exchange](https://grokking.realtemirov.uz/11.-where-to-go-next/9.-diffie-hellman-key-exchange)
* [Linear programming](https://grokking.realtemirov.uz/11.-where-to-go-next/10.-linear-programming)
* [Epilogue](https://grokking.realtemirov.uz/11.-where-to-go-next/11.-epilogue)

## Answers to exercises

* [Chapter 1](https://grokking.realtemirov.uz/12.-answers-to-exercises/chapter-1)
* [Chapter 2](https://grokking.realtemirov.uz/12.-answers-to-exercises/chapter-5)
* [Chapter 3](https://grokking.realtemirov.uz/12.-answers-to-exercises/chapter-6)
* [Chapter 4](https://grokking.realtemirov.uz/12.-answers-to-exercises/chapter-7)
* [Chapter 5](https://grokking.realtemirov.uz/12.-answers-to-exercises/chapter-8)
* [Chapter 6](https://grokking.realtemirov.uz/12.-answers-to-exercises/chapter-9)
* [Chapter 7](https://grokking.realtemirov.uz/12.-answers-to-exercises/chapter-10)
* [Chapter 8](https://grokking.realtemirov.uz/broken-reference)
* [Chapter 9](https://grokking.realtemirov.uz/broken-reference)
* [Chapter 10](https://grokking.realtemirov.uz/broken-reference)
