# deadvey/a-level-algorithms architecture

> Architecture diagram of the GitHub repository deadvey/a-level-algorithms, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-03-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/deadvey/a-level-algorithms
- Repository: https://github.com/deadvey/a-level-algorithms

## Overview

##### Project type and purpose
This repository is a **Python algorithms library / educational codebase**, not a deployed system. Its purpose is to provide **reference implementations of classic searching and sorting algorithms**:
- Searching: linear, binary
- Sorting: bubble, insertion, merge, quick

##### File structure analysis (what it implies architecturally)
Top-level layout:
- `README.md` — minimal description; no usage instructions, no CLI, no packaging metadata.
- `searching/`
- `linear.py`
- `binary.py`
- `.*.swp` — editor swap files (should be excluded from the “architecture”; optionally call out as non-source artifacts)
- `sorting/`
- `bubble.py`
- `insertion.py`
- `merge.py`
- `quick.py`

Architectural inference:
- This is **domain-folder organization** (by category), and **one algorithm per module**.
- No `src/`, no `setup.py`/`pyproject.toml`, no tests, no CI config: implies a **simple script-style repository** rather than a packaged library (though it can be turned into one).
- Inter-module dependencies are likely minimal; however, some algorithms (e.g., merge/quick) may have helper functions or recursion inside the file.

##### README insights
The README only declares:
- Language: Python
- A list of included algorithms

- Actor: `User / Notebook / Script`
- Container: `searching/`
- Node: `linear.py`
- Node: `binary.py`
- Container: `sorting/`
- Node: `bubble.py`
- Node: `insertion.py`
- Node: `merge.py`
- Node: `quick.py`
- Node: `README.md`
- Optional grey node: “Editor swap files (.swp) [ignore in runtime]”

## Diagram (Mermaid)

```mermaid
flowchart TD

%% =========================
%% Diagram A: Repo / Module Architecture
%% =========================

U["User / Notebook / Script<br/>(imports & calls)"]:::actor

subgraph R["Python Algorithms Repository"]
  README["README.md<br/>(Documentation)"]:::doc

  subgraph SEARCH["searching/ (Domain: Searching)"]
    LINS["linear.py<br/>(Linear Search)"]:::module
    BINS["binary.py<br/>(Binary Search;<br/>requires sorted input)"]:::module
    SWPL[".linear.py.swp<br/>(Editor artifact)"]:::artifact
    SWPB[".binary.py.swp<br/>(Editor artifact)"]:::artifact
  end

  subgraph SORT["sorting/ (Domain: Sorting)"]
    BUB["bubble.py<br/>(Bubble Sort)"]:::module
    INS["insertion.py<br/>(Insertion Sort)"]:::module
    MER["merge.py<br/>(Merge Sort)"]:::module
    QUI["quick.py<br/>(Quick Sort)"]:::module
  end
end

%% User interactions (imports/calls)
U -->|"imports/calls<br/>list[int]"| LINS
U -->|"imports/calls<br/>sorted list[int] + target"| BINS
U -->|"imports/calls<br/>list[int]"| BUB
U -->|"imports/calls<br/>list[int]"| INS
U -->|"imports/calls<br/>list[int]"| MER
U -->|"imports/calls<br/>list[int]"| QUI

%% Algorithm outputs (conceptual)
LINS -->|"returns<br/>index|None/-1"| U
BINS -->|"returns<br/>index|None/-1"| U
BUB -->|"returns<br/>sorted list[int]"| U
INS -->|"returns<br/>sorted list[int]"| U
MER -->|"returns<br/>sorted list[int]"| U
QUI -->|"returns<br/>sorted list[int]"| U

%% Semantic dependency: binary search needs sorted data
BUB -.->|"provides sorted input<br/>(precondition)"| BINS
INS -.->|"provides sorted input<br/>(precondition)"| BINS
MER -.->|"provides sorted input<br/>(precondition)"| BINS
QUI -.->|"provides sorted input<br/>(precondition)"| BINS

%% Docs relationships
README -.->|"documents"| SEARCH
README -.->|"documents"| SORT

%% Artifacts are non-runtime
SWPL -.->|"ignore in runtime"| SEARCH
SWPB -.->|"ignore in runtime"| SEARCH


%% =========================
%% Diagram B: Algorithm Flow (mini flowcharts)
%% =========================

subgraph FLOWS["Algorithm Flow Diagrams (Computation Architecture)"]
  direction TB

  subgraph F1["Linear Search (searching/linear.py)"]
    direction TB
    LS0(["Start: list + target"]):::step
    LS1["Iterate i from 0..n-1"]:::step
    LS2{"a[i] == target?"}:::decision
    LS3(["Return i"]):::return
    LS4(["End: Not found (None/-1)"]):::return
    LS0 --> LS1 --> LS2
    LS2 -->|"yes"| LS3
    LS2 -->|"no"| LS1
    LS1 -->|"done"| LS4
  end

  subgraph F2["Binary Search (searching/binary.py)"]
    direction TB
    BS0(["Start: sorted list + target"]):::step
    BS1["Initialize low=0, high=n-1"]:::step
    BS2{"low <= high?"}:::decision
    BS3["mid=(low+high)//2"]:::step
    BS4{"a[mid] == target?"}:::decision
    BS5(["Return mid"]):::return
    BS6{"a[mid] < target?"}:::decision
    BS7["low = mid + 1"]:::step
    BS8["high = mid - 1"]:::step
    BS9(["End: Not found (None/-1)"]):::return
    BS0 --> BS1 --> BS2
    BS2 -->|"no"| BS9
    BS2 -->|"yes"| BS3 --> BS4
    BS4 -->|"yes"| BS5
    BS4 -->|"no"| BS6
    BS6 -->|"yes"| BS7 --> BS2
    BS6 -->|"no"| BS8 --> BS2
  end

  subgraph F3["Merge Sort (sorting/merge.py)"]
    direction TB
    MS0(["Start: list"]):::step
    MS1{"len(list) <= 1?"}:::decision
    MS2(["Return list"]):::return
    MS3["Split into left/right halves"]:::step
    MS4["Recursively sort(left)"]:::step
    MS5["Recursively sort(right)"]:::step
    MS6["Merge(left,right)"]:::step
    MS7(["Return merged sorted list"]):::return
    MS0 --> MS1
    MS1 -->|"yes"| MS2
    MS1 -->|"no"| MS3 --> MS4 --> MS5 --> MS6 --> MS7
  end

  subgraph F4["Quick Sort (sorting/quick.py)"]
    direction TB
    QS0(["Start: list (in-place or new list)"]):::step
    QS1{"Base case?<br/>len<=1"}:::decision
    QS2(["Return list"]):::return
    QS3["Choose pivot"]:::step
    QS4["Partition: < pivot | pivot | > pivot"]:::step
    QS5["Recursively quicksort(left)"]:::step
    QS6["Recursively quicksort(right)"]:::step
    QS7(["Combine / return sorted"]):::return
    QS0 --> QS1
    QS1 -->|"yes"| QS2
    QS1 -->|"no"| QS3 --> QS4 --> QS5 --> QS6 --> QS7
  end
end


%% =========================
%% Click events (from mapping)
%% =========================
click README "https://github.com/deadvey/a-level-algorithms/blob/master/README.md"
click SEARCH "https://github.com/deadvey/a-level-algorithms/tree/master/searching/"
click LINS "https://github.com/deadvey/a-level-algorithms/blob/master/searching/linear.py"
click BINS "https://github.com/deadvey/a-level-algorithms/blob/master/searching/binary.py"
click SWPL "https://github.com/deadvey/a-level-algorithms/blob/master/searching/.linear.py.swp"
click SWPB "https://github.com/deadvey/a-level-algorithms/blob/master/searching/.binary.py.swp"
click SORT "https://github.com/deadvey/a-level-algorithms/tree/master/sorting/"
click BUB "https://github.com/deadvey/a-level-algorithms/blob/master/sorting/bubble.py"
click INS "https://github.com/deadvey/a-level-algorithms/blob/master/sorting/insertion.py"
click MER "https://github.com/deadvey/a-level-algorithms/blob/master/sorting/merge.py"
click QUI "https://github.com/deadvey/a-level-algorithms/blob/master/sorting/quick.py"


%% =========================
%% Styles
%% =========================
classDef repo fill:#0b1320,stroke:#89b4fa,stroke-width:1.5px,color:#e6edf3
classDef domain fill:#111c2e,stroke:#74c7ec,stroke-width:1.5px,color:#e6edf3
classDef module fill:#1f2a44,stroke:#a6e3a1,stroke-width:1.5px,color:#e6edf3
classDef actor fill:#2b1d3a,stroke:#cba6f7,stroke-width:1.5px,color:#e6edf3
classDef doc fill:#2a2a2a,stroke:#fab387,stroke-width:1.5px,color:#e6edf3
classDef artifact fill:#202020,stroke:#6c7086,stroke-width:1px,color:#a6adc8,stroke-dasharray: 4 3

classDef flows fill:#0b1320,stroke:#f9e2af,stroke-width:1.5px,color:#e6edf3
classDef flowbox fill:#0f172a,stroke:#f9e2af,stroke-width:1.2px,color:#e6edf3
classDef step fill:#111c2e,stroke:#89b4fa,stroke-width:1px,color:#e6edf3
classDef decision fill:#1c2233,stroke:#f38ba8,stroke-width:1.2px,color:#e6edf3
classDef return fill:#14223a,stroke:#a6e3a1,stroke-width:1.2px,color:#e6edf3

class R repo
class SEARCH,SORT domain
class FLOWS flows
class F1,F2,F3,F4 flowbox
```
