# ali7ali/mastering-algorithms-and-data-structures-in-php architecture

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

- Interactive diagram: https://gitdiagram.com/ali7ali/mastering-algorithms-and-data-structures-in-php
- Repository: https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php

## Overview

This repository is a collection of standalone PHP examples accompanying a course on algorithms and data structures, not a unified application. The learner-facing workflow is to study an example and run it to observe its behavior. The tree documents broad coverage, while sampled source confirms specific implementations; links between separate examples are omitted because they are not shown to call one another.

Main entry points: [`4-1/ex2-priorityqueue.php`](https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/4-1/ex2-priorityqueue.php) (Priority Queue), [`1-2/linear-time-ex.php`](https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/1-2/linear-time-ex.php) (Complexity Examples), [`1-3/array-manipulation-functions.php`](https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/1-3/array-manipulation-functions.php) (Array Examples), [`2-1/ex3-insert-remove-nodes-linkedlist.php`](https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/2-1/ex3-insert-remove-nodes-linkedlist.php) (Linked List)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_foundations["Foundations"]
  node_complexity["Complexity Examples<br/>[linear-time-ex.php]"]
  node_arrays["Array Examples"]
  node_arraytypes["Array Types<br/>[array-types.php]"]
end

subgraph group_structures["Data Structures"]
  node_linkedlist["Linked List"]
  node_stack["Stack<br/>[ex1-stack.php]"]
  node_queue["Queue<br/>[ex2-queue.php]"]
  node_associative["Associative Arrays"]
  node_counting["Occurrence Counting"]
  node_binarytree["Binary Tree"]
  node_bst["Search Tree"]
  node_priority["Priority Queue"]
  node_minheap["Min Heap"]
end

subgraph group_searchsort["Search and Sort"]
  node_bubble["Bubble Sort<br/>[ex1-bubblesort.php]"]
  node_insertion["Insertion Sort"]
  node_selection["Selection Sort"]
  node_merge["Merge Sort<br/>[ex1-mergesort.php]"]
  node_quick["Quick Sort<br/>[ex2-quicksort.php]"]
  node_linear["Linear Search"]
  node_binary["Binary Search"]
  node_library["Algorithm Library"]
  node_librarybinary["Library Binary Search<br/>[BinarySearch.php]"]
end

subgraph group_graphs["Graph Algorithms"]
  node_adjlist["Adjacency List"]
  node_adjmatrix["Adjacency Matrix"]
  node_bfs["Breadth-First Search<br/>[ex1-bfs.php]"]
  node_dfs["Depth-First Search<br/>[ex2.dfs.php]"]
  node_dijkstra["Dijkstra Example<br/>[ex3-dijkstra.php]"]
  node_librarybfs["Library BFS"]
end

subgraph group_optimization["Optimization"]
  node_recursion["Recursive Examples<br/>[ex1-factorial.php]"]
  node_memoization["Memoization"]
  node_dynamic["Dynamic Programming<br/>[ex2-dynamic.php]"]
  node_knapsack["Knapsack<br/>[ex3-knapsack.php]"]
  node_greedy["Greedy Examples<br/>[ex1-greedyalgo.php]"]
  node_nearest["Nearest Neighbor"]
end

node_learner(("Learner"))

node_learner -->|"studies"| node_complexity
node_learner -->|"studies"| node_arrays
node_learner -->|"studies"| node_linkedlist
node_learner -->|"studies"| node_bubble
node_learner -->|"studies"| node_bfs
node_learner -->|"studies"| node_recursion
node_learner -->|"studies"| node_library
node_priority -->|"delegates"| node_minheap

click node_complexity "https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/1-2/linear-time-ex.php"
click node_arrays "https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/1-3/array-manipulation-functions.php"
click node_arraytypes "https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/1-3/array-types.php"
click node_linkedlist "https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/2-1/ex3-insert-remove-nodes-linkedlist.php"
click node_stack "https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/2-2/ex1-stack.php"
click node_queue "https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/2-2/ex2-queue.php"
click node_associative "https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/2-3/ex1-associative-array.php"
click node_counting "https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/2-3/ex2-counting-occurrences.php"
click node_binarytree "https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/2-4/ex1-binary-tree.php"
click node_bst "https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/2-4/ex2-binary-search-tree.php"
click node_bubble "https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/3-1/ex1-bubblesort.php"
click node_insertion "https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/3-1/ex2-insertionsort.php"
click node_selection "https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/3-1/ex3-selectionsort.php"
click node_merge "https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/3-2/ex1-mergesort.php"
click node_quick "https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/3-2/ex2-quicksort.php"
click node_linear "https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/3-3/ex1-linearsearch.php"
click node_binary "https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/3-3/ex2-binarysearch.php"
click node_priority "https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/4-1/ex2-priorityqueue.php"
click node_minheap "https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/4-1/ex2-priorityqueue.php"
click node_adjlist "https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/4-2/ex1-adjacencylist.php"
click node_adjmatrix "https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/4-2/ex2-adjacencymatrix.php"
click node_bfs "https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/4-3/ex1-bfs.php"
click node_dfs "https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/4-3/ex2.dfs.php"
click node_dijkstra "https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/4-3/ex3-dijkstra.php"
click node_recursion "https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/5-1/ex1-factorial.php"
click node_memoization "https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/5-2/ex1-memoization.php"
click node_dynamic "https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/5-2/ex2-dynamic.php"
click node_knapsack "https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/5-2/ex3-knapsack.php"
click node_greedy "https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/6-1/ex1-greedyalgo.php"
click node_nearest "https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/6-1/ex2-nearest-neighbor-algo.php"
click node_library "https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/tree/main/6-2/php-algorithm-library"
click node_librarybfs "https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/6-2/php-algorithm-library/graph/BreadthFirstSearch.php"
click node_librarybinary "https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/6-2/php-algorithm-library/searching/BinarySearch.php"

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_complexity,node_arrays,node_arraytypes toneBlue
class node_linkedlist,node_stack,node_queue,node_associative,node_counting,node_binarytree,node_bst,node_priority,node_minheap toneAmber
class node_bubble,node_insertion,node_selection,node_merge,node_quick,node_linear,node_binary,node_library,node_librarybinary toneMint
class node_adjlist,node_adjmatrix,node_bfs,node_dfs,node_dijkstra,node_librarybfs toneRose
class node_recursion,node_memoization,node_dynamic,node_knapsack,node_greedy,node_nearest,node_learner toneIndigo
```

## Components

### Foundations

- [Complexity Examples](https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/1-2/linear-time-ex.php): `1-2/linear-time-ex.php`
- [Array Examples](https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/1-3/array-manipulation-functions.php): `1-3/array-manipulation-functions.php`
- [Array Types](https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/1-3/array-types.php): `1-3/array-types.php`

### Data Structures

- [Linked List](https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/2-1/ex3-insert-remove-nodes-linkedlist.php): `2-1/ex3-insert-remove-nodes-linkedlist.php`
- [Stack](https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/2-2/ex1-stack.php): `2-2/ex1-stack.php`
- [Queue](https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/2-2/ex2-queue.php): `2-2/ex2-queue.php`
- [Associative Arrays](https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/2-3/ex1-associative-array.php): `2-3/ex1-associative-array.php`
- [Occurrence Counting](https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/2-3/ex2-counting-occurrences.php): `2-3/ex2-counting-occurrences.php`
- [Binary Tree](https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/2-4/ex1-binary-tree.php): `2-4/ex1-binary-tree.php`
- [Search Tree](https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/2-4/ex2-binary-search-tree.php): `2-4/ex2-binary-search-tree.php`
- [Priority Queue](https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/4-1/ex2-priorityqueue.php): `4-1/ex2-priorityqueue.php`
- [Min Heap](https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/4-1/ex2-priorityqueue.php): `4-1/ex2-priorityqueue.php`

### Search and Sort

- [Bubble Sort](https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/3-1/ex1-bubblesort.php): `3-1/ex1-bubblesort.php`
- [Insertion Sort](https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/3-1/ex2-insertionsort.php): `3-1/ex2-insertionsort.php`
- [Selection Sort](https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/3-1/ex3-selectionsort.php): `3-1/ex3-selectionsort.php`
- [Merge Sort](https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/3-2/ex1-mergesort.php): `3-2/ex1-mergesort.php`
- [Quick Sort](https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/3-2/ex2-quicksort.php): `3-2/ex2-quicksort.php`
- [Linear Search](https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/3-3/ex1-linearsearch.php): `3-3/ex1-linearsearch.php`
- [Binary Search](https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/3-3/ex2-binarysearch.php): `3-3/ex2-binarysearch.php`
- [Algorithm Library](https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/tree/main/6-2/php-algorithm-library): `6-2/php-algorithm-library`
- [Library Binary Search](https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/6-2/php-algorithm-library/searching/BinarySearch.php): `6-2/php-algorithm-library/searching/BinarySearch.php`

### Graph Algorithms

- [Adjacency List](https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/4-2/ex1-adjacencylist.php): `4-2/ex1-adjacencylist.php`
- [Adjacency Matrix](https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/4-2/ex2-adjacencymatrix.php): `4-2/ex2-adjacencymatrix.php`
- [Breadth-First Search](https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/4-3/ex1-bfs.php): `4-3/ex1-bfs.php`
- [Depth-First Search](https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/4-3/ex2.dfs.php): `4-3/ex2.dfs.php`
- [Dijkstra Example](https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/4-3/ex3-dijkstra.php): `4-3/ex3-dijkstra.php`
- [Library BFS](https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/6-2/php-algorithm-library/graph/BreadthFirstSearch.php): `6-2/php-algorithm-library/graph/BreadthFirstSearch.php`

### Optimization

- [Recursive Examples](https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/5-1/ex1-factorial.php): `5-1/ex1-factorial.php`
- [Memoization](https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/5-2/ex1-memoization.php): `5-2/ex1-memoization.php`
- [Dynamic Programming](https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/5-2/ex2-dynamic.php): `5-2/ex2-dynamic.php`
- [Knapsack](https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/5-2/ex3-knapsack.php): `5-2/ex3-knapsack.php`
- [Greedy Examples](https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/6-1/ex1-greedyalgo.php): `6-1/ex1-greedyalgo.php`
- [Nearest Neighbor](https://github.com/ali7ali/mastering-algorithms-and-data-structures-in-php/blob/main/6-1/ex2-nearest-neighbor-algo.php): `6-1/ex2-nearest-neighbor-algo.php`

### Other components

- **Learner**

## Connections

- Learner → Complexity Examples: studies
- Learner → Array Examples: studies
- Learner → Linked List: studies
- Learner → Bubble Sort: studies
- Learner → Breadth-First Search: studies
- Learner → Recursive Examples: studies
- Learner → Algorithm Library: studies
- Priority Queue → Min Heap: delegates
