# ibtisam345/grokking-algorithm architecture

> Architecture diagram of the GitHub repository ibtisam345/grokking-algorithm, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ibtisam345/grokking-algorithm
- Repository: https://github.com/ibtisam345/grokking-algorithm

## Overview

This repository is a set of chapter-by-chapter algorithm examples, not a single application. Its main workflow is to run a standalone example with sample input and observe a result; it also provides reusable functions for searching, sorting, recursion, voter lookup, and graph traversal. The BFS example embeds its own graph, while `graph.py` separately prints an adjacency map. The README identifies these as learning exercises. Edges reflect only calls and example execution shown in the excerpts; unimplemented topics listed as future progress are omitted.

Main entry points: [`Chapter 06/breadth_first_search.py`](https://github.com/ibtisam345/grokking-algorithm/blob/main/Chapter%2006/breadth_first_search.py) (Breadth-first search), [`Chapter 02/selection_sort.py`](https://github.com/ibtisam345/grokking-algorithm/blob/main/Chapter%2002/selection_sort.py) (Selection sort), [`Chapter 01/binary_search.py`](https://github.com/ibtisam345/grokking-algorithm/blob/main/Chapter%2001/binary_search.py) (Binary search (Python)), [`Chapter 01/binary_search.c`](https://github.com/ibtisam345/grokking-algorithm/blob/main/Chapter%2001/binary_search.c) (Binary search (C))

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_search["Searching"]
  node_binary_py["Binary search &#40;Python&#41;<br/>[binary_search.py]"]
  node_binary_c["Binary search &#40;C&#41;<br/>[binary_search.c]"]
  node_linear["Linear search<br/>[linear_search.py]"]
end

subgraph group_sorting["Sorting"]
  node_selection["Selection sort<br/>[selection_sort.py]"]
  node_find_smallest["Find smallest<br/>[selection_sort.py]"]
  node_quicksort["Quicksort<br/>[Quick_sort.py]"]
end

subgraph group_recursion["Recursion"]
  node_factorial["Factorial<br/>[factorial.py]"]
  node_recursive_sum["Recursive sum<br/>[4.1.py]"]
  node_recursive_count["Recursive count<br/>[4.2.py]"]
  node_recursive_max["Recursive maximum<br/>[4.3.py]"]
end

subgraph group_lookup["Lookup and graphs"]
  node_voter_check["Voter check<br/>[voter_check.py]"]
  node_bfs_graph[("BFS example graph")]
  node_seller_predicate["Seller predicate"]
  node_bfs["Breadth-first search"]
  node_graph_example["Adjacency map example<br/>[graph.py]"]
end

node_user(("Learner"))

node_user -->|"runs example"| node_binary_py
node_user -->|"runs example"| node_binary_c
node_user -->|"runs example"| node_linear
node_user -->|"runs example"| node_selection
node_selection -->|"calls"| node_find_smallest
node_user -->|"runs example"| node_quicksort
node_user -->|"runs example"| node_factorial
node_user -->|"runs example"| node_recursive_sum
node_user -->|"runs example"| node_recursive_count
node_user -->|"runs example"| node_recursive_max
node_bfs -->|"reads neighbors"| node_bfs_graph
node_bfs -->|"checks seller"| node_seller_predicate
node_user -->|"runs search"| node_bfs
node_user -->|"runs example"| node_graph_example

click node_binary_py "https://github.com/ibtisam345/grokking-algorithm/blob/main/Chapter%2001/binary_search.py"
click node_binary_c "https://github.com/ibtisam345/grokking-algorithm/blob/main/Chapter%2001/binary_search.c"
click node_linear "https://github.com/ibtisam345/grokking-algorithm/blob/main/Chapter%2001/linear_search.py"
click node_selection "https://github.com/ibtisam345/grokking-algorithm/blob/main/Chapter%2002/selection_sort.py"
click node_find_smallest "https://github.com/ibtisam345/grokking-algorithm/blob/main/Chapter%2002/selection_sort.py"
click node_quicksort "https://github.com/ibtisam345/grokking-algorithm/blob/main/Chapter%2004/Code/Quick_sort.py"
click node_factorial "https://github.com/ibtisam345/grokking-algorithm/blob/main/Chapter%2003/factorial.py"
click node_recursive_sum "https://github.com/ibtisam345/grokking-algorithm/blob/main/Chapter%2004/Exercises/4.1.py"
click node_recursive_count "https://github.com/ibtisam345/grokking-algorithm/blob/main/Chapter%2004/Exercises/4.2.py"
click node_recursive_max "https://github.com/ibtisam345/grokking-algorithm/blob/main/Chapter%2004/Exercises/4.3.py"
click node_voter_check "https://github.com/ibtisam345/grokking-algorithm/blob/main/Chapter%2005/voter_check.py"
click node_bfs_graph "https://github.com/ibtisam345/grokking-algorithm/blob/main/Chapter%2006/breadth_first_search.py"
click node_seller_predicate "https://github.com/ibtisam345/grokking-algorithm/blob/main/Chapter%2006/breadth_first_search.py"
click node_bfs "https://github.com/ibtisam345/grokking-algorithm/blob/main/Chapter%2006/breadth_first_search.py"
click node_graph_example "https://github.com/ibtisam345/grokking-algorithm/blob/main/Chapter%2006/graph.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_binary_py,node_binary_c,node_linear toneBlue
class node_selection,node_find_smallest,node_quicksort toneAmber
class node_factorial,node_recursive_sum,node_recursive_count,node_recursive_max toneMint
class node_voter_check,node_bfs_graph,node_seller_predicate,node_bfs,node_graph_example toneRose
class node_user toneIndigo
```

## Components

### Searching

- [Binary search (Python)](https://github.com/ibtisam345/grokking-algorithm/blob/main/Chapter%2001/binary_search.py): `Chapter 01/binary_search.py`
- [Binary search (C)](https://github.com/ibtisam345/grokking-algorithm/blob/main/Chapter%2001/binary_search.c): `Chapter 01/binary_search.c`
- [Linear search](https://github.com/ibtisam345/grokking-algorithm/blob/main/Chapter%2001/linear_search.py): `Chapter 01/linear_search.py`

### Sorting

- [Selection sort](https://github.com/ibtisam345/grokking-algorithm/blob/main/Chapter%2002/selection_sort.py): `Chapter 02/selection_sort.py`
- [Find smallest](https://github.com/ibtisam345/grokking-algorithm/blob/main/Chapter%2002/selection_sort.py): `Chapter 02/selection_sort.py`
- [Quicksort](https://github.com/ibtisam345/grokking-algorithm/blob/main/Chapter%2004/Code/Quick_sort.py): `Chapter 04/Code/Quick_sort.py`

### Recursion

- [Factorial](https://github.com/ibtisam345/grokking-algorithm/blob/main/Chapter%2003/factorial.py): `Chapter 03/factorial.py`
- [Recursive sum](https://github.com/ibtisam345/grokking-algorithm/blob/main/Chapter%2004/Exercises/4.1.py): `Chapter 04/Exercises/4.1.py`
- [Recursive count](https://github.com/ibtisam345/grokking-algorithm/blob/main/Chapter%2004/Exercises/4.2.py): `Chapter 04/Exercises/4.2.py`
- [Recursive maximum](https://github.com/ibtisam345/grokking-algorithm/blob/main/Chapter%2004/Exercises/4.3.py): `Chapter 04/Exercises/4.3.py`

### Lookup and graphs

- [Voter check](https://github.com/ibtisam345/grokking-algorithm/blob/main/Chapter%2005/voter_check.py): `Chapter 05/voter_check.py`
- [BFS example graph](https://github.com/ibtisam345/grokking-algorithm/blob/main/Chapter%2006/breadth_first_search.py): `Chapter 06/breadth_first_search.py`
- [Seller predicate](https://github.com/ibtisam345/grokking-algorithm/blob/main/Chapter%2006/breadth_first_search.py): `Chapter 06/breadth_first_search.py`
- [Breadth-first search](https://github.com/ibtisam345/grokking-algorithm/blob/main/Chapter%2006/breadth_first_search.py): `Chapter 06/breadth_first_search.py`
- [Adjacency map example](https://github.com/ibtisam345/grokking-algorithm/blob/main/Chapter%2006/graph.py): `Chapter 06/graph.py`

### Other components

- **Learner**

## Connections

- Learner → Binary search (Python): runs example (evidence: `Chapter 01/binary_search.py`)
- Learner → Binary search (C): runs example (evidence: `Chapter 01/binary_search.c`)
- Learner → Linear search: runs example (evidence: `Chapter 01/linear_search.py`)
- Learner → Selection sort: runs example (evidence: `Chapter 02/selection_sort.py`)
- Selection sort → Find smallest: calls (evidence: `Chapter 02/selection_sort.py`)
- Learner → Quicksort: runs example (evidence: `Chapter 04/Code/Quick_sort.py`)
- Learner → Factorial: runs example (evidence: `Chapter 03/factorial.py`)
- Learner → Recursive sum: runs example (evidence: `Chapter 04/Exercises/4.1.py`)
- Learner → Recursive count: runs example (evidence: `Chapter 04/Exercises/4.2.py`)
- Learner → Recursive maximum: runs example (evidence: `Chapter 04/Exercises/4.3.py`)
- Breadth-first search → BFS example graph: reads neighbors (evidence: `Chapter 06/breadth_first_search.py`)
- Breadth-first search → Seller predicate: checks seller (evidence: `Chapter 06/breadth_first_search.py`)
- Learner → Breadth-first search: runs search (evidence: `Chapter 06/breadth_first_search.py`)
- Learner → Adjacency map example: runs example (evidence: `Chapter 06/graph.py`)
