A modular, console-based Data Structures & Algorithms library written entirely in C, built from scratch with pointer-level control, manual memory management (malloc / free), and defensive input validation.
This project emphasizes conceptual clarity, low-level fundamentals, and explicit memory reasoning. It is designed with an educational intent, allowing learners to observe, experiment with, and understand data structures and algorithms step-by-step through an interactive terminal-based interface.
The codebase is structured as a reusable DSA library, with an interactive, console-driven demo layer built on top.
- Demos
- Build Instructions
- Continuous Integration
- Architectural Breakdown: Docker & The Build System
- List of All Implemented Data Structures & Algorithms
- License
This project includes a Makefile and CMakeLists.txt to simplify building across multiple directories.
- GNU Make ≥ 4.4.1
- GCC (or a compatible C compiler)
The Text User Interface (TUI) is built using the Ncurses library.
sudo apt install libncurses5-dev libncursesw5-devsudo dnf install ncurses-develsudo pacman -S ncursesNote: The TUI is supported on Unix/Linux systems. On Windows, the project automatically falls back to the legacy CLI interface.
makeThis generates a single executable:
dsa(Linux / macOS)dsa.exe(Windows)
Alternatively, you can compile the application and tests using CMake:
mkdir build && cd build
cmake ..
makeTo execute all unit tests using CTest:
ctest --output-on-failuremake run Builds only when necessary and launches the program.
make testRuns all tests and generates test binaries
make fmtOrganizes code style according to the standards defined in .clang-format
make valgrindRuns Valgrind over test binaries to look for memory leaks / use after free errors
make cleanRemoves executables and generated object/test binaries.
This project includes a GitHub Actions CI pipeline that automatically verifies code correctness and memory safety.
On every push or pull request:
-
A fresh Ubuntu VM is allocated
-
The project is compiled using GCC
-
The
make fmtis run on the runner and checked with your code, if they dont match, CI turns red -
The complete unit test suite is executed
-
All test binaries are run under Valgrind to check for:
-
The project is sanitized under asan and ubsan and tests are run to check for undefined behaviour (ie semantic errors)
- unformatted code
- memory leaks
- invalid reads / writes
- use-after-free errors
- uninitialized memory usage
If any test fails or Valgrind detects a memory error, the CI job fails automatically.
The C DSA Interactive Suite is organized into a modular four-tier architecture:
- UI & Driver Layer:
src/main.c(CLI prompt driver & command flag parser),tui/tui.c(Ncurses/ANSI dual-pane visualizer dashboard), andsrc/utils/algorithm_search.c(live search index). - Telemetry & Utility Layer: Live Step-Debugger (
features/debugger/), Memory Profiler (features/memory_inspector/), File & Source Exporters (features/file_exporter/), State Serialization (features/serialization/), and Big-O Verifier & Benchmark Suites (features/bigo_verifier/,features/benchmark/). - Core Library Engine (
libdsa_lib.a): Static C library housing all dynamic data structures, standard/spatial trees, graph algorithms, dynamic programming solvers, probabilistic data structures, OS/hardware simulators, and error correction/bit operations.
flowchart TD
subgraph UI_Layer ["Terminal Interface & Driver Layer"]
CLI["src/main.c (CLI Driver & Flag Processor)"]
TUI["tui/tui.c (Ncurses/ANSI Dual-Pane Visualizer)"]
Search["src/utils/algorithm_search.c (Algorithm Search Registry)"]
end
subgraph Feature_Layer ["Interactive Telemetry & Utility Engines"]
Debugger["features/debugger (Step Debugger & Telemetry Bridge)"]
Inspector["features/memory_inspector (Live Heap Memory Map)"]
Exporter["features/file_exporter (Source & State Exporters)"]
Serializer["features/serialization (File State Persistence)"]
Verifier["features/bigo_verifier (Empirical Big-O Analysis)"]
Bench["features/benchmark (Multi-Algorithm Stress Tests)"]
end
subgraph Core_Library ["libdsa_lib.a Core Algorithms Engine"]
subgraph DS_Trees ["Data Structures & Trees"]
SLL["Lists & Queues (SLL, DLL, Stack, Circular Queue)"]
Trees["BST, AVL, B-Tree, Splay, Fenwick, Red-Black"]
Spatial["Spatial Indexing (k-d Tree, QuadTree, R-Tree)"]
end
subgraph Graph_Algos ["Graphs & DP"]
Traversals["Traversals & Paths (BFS, DFS, Dijkstra, A*, Floyd-Warshall)"]
Flow["Advanced Graph (Max Flow, SCC, Eulerian, Bipartite)"]
DP["Dynamic Programming (Knapsack, LCS, MCM, Coin Change)"]
end
subgraph Advanced_Models ["Probabilistic & Systems"]
Prob["Probabilistic DS (Bloom Filter, Count-Min, HyperLogLog)"]
System["OS & Hardware (Process Sync, Cache Simulator, Fuzzer)"]
ErrorBit["Bit & Info Theory (CRC, Hamming, Checksum, Bit Ops)"]
end
end
CLI -->|Launch CLI Demos| Core_Library
CLI -->|Run Features| Feature_Layer
TUI -->|Search & Launch| Search
Search -->|Map Selection| Core_Library
Feature_Layer -->|Inspect & Profile| Core_Library
TUI -->|Render Telemetry| Debugger
TUI -->|Render Heap Map| Inspector
Docker acts as a cross-platform wrapper around the build system. Contributors on Windows, macOS, and Linux can use the same isolated Ubuntu environment without manually configuring compiler toolchains, build dependencies, or platform-specific settings.
The current build flow is:
Docker Container
↓
Makefile
↓
GCC Compilation
↓
dsa Executable
The Docker image installs the required build tools and executes the project's Makefile, ensuring consistent builds across different operating systems.
Each component serves a different purpose:
- Docker provides a reproducible Linux build environment.
- The Makefile defines the primary build workflow used by the project today.
- CMakeLists.txt provides an alternative build system that can generate platform-specific build files while supporting testing and future expansion.
These tools are complementary rather than competing solutions.
Helper targets have been added to the local Makefile to simplify building, running, and testing inside Docker:
| Command | Description |
|---|---|
make docker-test |
Builds the dev stage and runs the complete unit test suite inside it. |
make docker-run |
Builds the runtime stage and launches the interactive application shell. |
make docker-build-dev |
Builds the development stage image (c-dsa-suite:dev). |
make docker-build-runtime |
Builds the slim production stage image (c-dsa-suite:slim). |
The project uses a multi-stage Dockerfile to separate the build environment from the lightweight runtime image:
- Stage 1 (
dev): A heavy development environment containing the full C build toolchain,valgrind,gdb, and the complete source repository. - Stage 2 (
runtime): A minimal image packaging only the compiled binary andlibncurses6runtime library (no source code or compiler).
This suite includes over 100+ interactive, memory-audited data structures and algorithms organized across 21+ core module categories. Each entry is mapped to its CLI main menu option and includes time and space complexity breakdowns.
| Data Structure / Algorithm | Category | Time Complexity (Best / Avg / Worst) | Space Complexity | Description |
|---|---|---|---|---|
| Singly Linked List | Linear Data Structures | Dynamic single-pointer linked nodes with traversal and insertion. | ||
| Doubly Linked List | Linear Data Structures | Bi-directional pointer navigation with head/tail tracking. | ||
| Circular Linked List | Linear Data Structures | Ring-buffer linked structure with continuous looping. | ||
| Stack (Array & Linked List) | LIFO Structure | Last-In-First-Out push, pop, and peek operations. | ||
| Queue (Array & Linked List) | FIFO Structure | First-In-First-Out enqueue and dequeue operations. |
| Module / Algorithm | Category | Time Complexity | Space Complexity | Description |
|---|---|---|---|---|
| Infix to Postfix Conversion | Expression Parsing | Converts infix arithmetic expressions using Shunting-yard algorithm. | ||
| Infix to Prefix Conversion | Expression Parsing | Reverses and transforms infix expressions to polish prefix notation. | ||
| Postfix Expression Evaluator | Expression Evaluation | Evaluates postfix token stream using operand stack. | ||
| Parentheses Match Checker | Syntax Validation | Validates balanced parentheses, brackets, and braces (), [], {}. |
| Algorithm | Category | Time Complexity (Best / Avg / Worst) | Space Complexity | Description |
|---|---|---|---|---|
| Bubble Sort (Optimized) | Elementary Sorting | Swaps adjacent out-of-order elements with early-exit flag. | ||
| Selection Sort | Elementary Sorting | Repeatedly finds the minimum element from unsorted subarray. | ||
| Insertion Sort | Elementary Sorting | Builds sorted array one item at a time by shifting elements. | ||
| Shell Sort | Elementary Sorting | In-place comparison sort using diminishing gap increments. |
| Algorithm | Category | Time Complexity (Best / Avg / Worst) | Space Complexity | Description |
|---|---|---|---|---|
| Quick Sort | Divide & Conquer | Partitions array around a pivot element recursively. | ||
| Merge Sort | Divide & Conquer | Stable divide-and-conquer sorting by merging sorted sub-arrays. | ||
| Heap Sort | Tree-based Sorting | In-place comparison sort using binary max-heap heapify. | ||
| Radix Sort | Non-comparison Sort | Digit-by-digit distribution sort using counting sort buckets. | ||
| Bucket Sort | Distribution Sort | Distributes elements into uniform floating-point buckets. | ||
| Counting Sort | Non-comparison Sort | Integer sorting by counting element occurrences. |
| Algorithm | Category | Time Complexity (Best / Avg / Worst) | Space Complexity | Description |
|---|---|---|---|---|
| Linear Search | Sequential Search | Sequential element comparison across unsorted arrays. | ||
| Binary Search (Iterative & Recursive) | Logarithmic Search |
|
Divide-and-conquer search on sorted arrays. | |
| Jump Search | Block Search | Jumps ahead by fixed steps ( |
||
| Interpolation Search | Position Estimator | Position probe search for uniformly distributed sorted arrays. | ||
| Fibonacci Search | Logarithmic Search | Narrows down range using Fibonacci numbers, avoiding division. |
| Algorithm | Category | Time Complexity | Space Complexity | Description |
|---|---|---|---|---|
| Breadth-First Search (BFS) | Graph Traversal | Level-order graph traversal using queue data structure. | ||
| Depth-First Search (DFS) | Graph Traversal | Deep path exploration using recursion stack. | ||
| Dijkstra Shortest Path | Single-Source Path | Shortest path algorithm for non-negative weighted graphs. | ||
| A* Search | Heuristic Pathfinding | Informed pathfinding using Manhattan/Euclidean distance heuristics. | ||
| Greedy Best-First Search | Heuristic Pathfinding | Evaluates node distance using purely heuristic estimation. | ||
| Bellman-Ford Algorithm | Single-Source Path | Handles negative weight edges and detects negative cycles. | ||
| Topological Sort | Graph Order | Linear ordering of vertices in Directed Acyclic Graphs (DAGs). | ||
| Kruskal's Algorithm | Minimum Spanning Tree | MST construction using Disjoint Set Union (DSU) find-set. | ||
| Prim's Algorithm | Minimum Spanning Tree | Greedy MST growth from seed vertex using priority queue. | ||
| Floyd-Warshall Algorithm | All-Pairs Shortest Path | All-pairs shortest path dynamic programming matrix solver. |
| Algorithm | Category | Time Complexity | Space Complexity | Description |
|---|---|---|---|---|
| Tarjan's SCC Algorithm | Graph Connectivity | Strongly Connected Components using DFS lowlink values. | ||
| Kosaraju's SCC Algorithm | Graph Connectivity | Two-pass DFS strongly connected component finder. | ||
| Ford-Fulkerson Algorithm | Network Flow | $\mathcal{O}(E \cdot | f_{max} | )$ |
| Edmonds-Karp Algorithm | Network Flow | BFS-based max flow implementation of Ford-Fulkerson. | ||
| Dinic's Algorithm | Network Flow | Level-graph blocking flow network max flow solver. | ||
| Hopcroft-Karp Algorithm | Bipartite Matching | Maximum cardinality matching on bipartite graphs. | ||
| Eulerian Path & Circuit | Graph Walk | Validates and constructs Eulerian trails using Hierholzer's algorithm. | ||
| Articulation Points Analysis | Network Vulnerability | Identifies cut-vertices whose removal disconnects the graph. | ||
| Bridges Analysis | Network Vulnerability | Identifies critical edges whose deletion increases components. | ||
| Network Vulnerability Simulator | Network Resilience | Interactive resilience testing and critical failure simulation. |
| Hash Technique | Category | Time Complexity (Avg / Worst) | Space Complexity | Description |
|---|---|---|---|---|
| Separate Chaining | Open Hashing | Collision resolution via linked lists per table bucket. | ||
| Linear Probing | Closed Hashing | Open addressing with sequential index step probing. | ||
| Quadratic Probing | Closed Hashing | Open addressing with quadratic step |
||
| Double Hashing | Closed Hashing | Open addressing using independent secondary hash function. |
| Data Structure | Category | Time Complexity (Search / Insert / Delete) | Space Complexity | Description |
|---|---|---|---|---|
| Binary Search Tree (BST) | Binary Tree | Standard ordered binary search tree. | ||
| AVL Tree | Self-Balancing Tree | Height-balanced binary tree using LL, RR, LR, RL rotations. | ||
| Threaded Binary Tree (TBT) | Tree Traversal | Fast in-order traversal using NULL pointer thread pointers. | ||
| Trie (Prefix Tree) | String Tree | Prefix search tree for string dictionaries and autocompletion. | ||
| B-Tree | Multi-Way Tree | Self-balancing |
||
| B+ Tree | Multi-Way Tree | Sequential leaf-linked multi-way tree for range queries. | ||
| Segment Tree | Range Query Tree | Binary tree for range minimum, maximum, and sum queries. | ||
| Fenwick Tree (BIT) | Range Query Tree | Compact binary indexed tree for dynamic prefix sums. | ||
| Splay Tree | Self-Adjusting Tree | Amortized self-adjusting search tree moving recent nodes to root. | ||
| Red-Black Tree | Self-Balancing Tree | Color-balanced binary search tree using black-height invariant. |
| Algorithm | Category | Time Complexity | Space Complexity | Description |
|---|---|---|---|---|
| Checksum Validation | Data Integrity | Simple additive sum verification across byte streams. | ||
| Cyclic Redundancy Check (CRC-32) | Error Detection | Polynomial division remainder calculation for burst errors. | ||
| Hamming Code (7,4) | Error Correction | Single-error correction and double-error detection (SEC-DED). | ||
| Vertical Redundancy Check (VRC) | Error Detection | Single parity bit verification per character. | ||
| Longitudinal Redundancy Check (LRC) | Error Detection | Block parity bit calculation across character streams. |
| Simulator / Problem | Category | Complexity | Description |
|---|---|---|---|
| Peterson's Algorithm | Concurrency |
|
2-process mutual exclusion with flags and turn variables. |
| Dining Philosophers Problem | Deadlock Simulation |
|
Simulates resource contention, circular wait, and asymmetric fixes. |
| Readers-Writers Problem | Semaphore Sync |
|
Priority reader/writer access control via semaphores. |
| Producer-Consumer Problem | Bounded Buffer |
|
Bounded buffer synchronization with mutexes and condition variables. |
| Scheduling Policy | Category | Preemptive | Complexity | Description |
|---|---|---|---|---|
| First-Come First-Served (FCFS) | CPU Scheduling | No | Non-preemptive arrival order job execution. | |
| Shortest Job First (SJF) | CPU Scheduling | No | Non-preemptive shortest burst time job scheduling. | |
| Shortest Remaining Time First (SRTF) | CPU Scheduling | Yes | Preemptive shortest remaining burst time scheduling. | |
| Priority Scheduling | CPU Scheduling | No | Non-preemptive priority-rank based process execution. | |
| Preemptive Priority Scheduling | CPU Scheduling | Yes | Preemptive higher-priority job execution. | |
| Round Robin (RR) | CPU Scheduling | Yes | Preemptive time-slice quantum round-robin scheduler. |
| Algorithm / Problem | Category | Time Complexity | Space Complexity | Description |
|---|---|---|---|---|
| Knight's Tour Problem | Backtracking | Warnsdorff's heuristic knight's tour board traversal. | ||
| N-Queens Problem | Backtracking | Places |
||
| Sudoku Solver | Backtracking | Backtracking constraint satisfaction 9x9 grid solver. | ||
| Subset Sum Problem | Backtracking | Finds subsets matching target sum using pruning. | ||
| Rat in a Maze | Backtracking | Grid maze pathfinding from source to destination. |
| Algorithm / Problem | Category | Time Complexity | Space Complexity | Description |
|---|---|---|---|---|
| 0/1 Knapsack Problem | Optimization DP | Maximizes item values under capacity constraint |
||
| Longest Common Subsequence (LCS) | String DP | Computes longest common subsequence between two strings. | ||
| Fibonacci Sequence (DP) | Recurrence DP | Memoization & tabulation approach to Fibonacci numbers. | ||
| Matrix Chain Multiplication (MCM) | Matrix DP | Optimal parenthesization for minimal scalar matrix operations. | ||
| Edit Distance (Levenshtein) | String DP | Minimum insertion, deletion, and replacement operations. | ||
| Coin Change Problem | Optimization DP | Minimum coins needed to make target amount |
| Algorithm | Category | Time Complexity | Space Complexity | Description |
|---|---|---|---|---|
| Huffman Coding | Lossless Compression | Prefix-free variable-length entropy encoding. | ||
| Run-Length Encoding (RLE) | Lossless Compression | Replaces consecutive repeated characters with run counts. | ||
| LZW Compression | Dictionary Compression | Dictionary-based string substitution algorithm. | ||
| Burrows-Wheeler Transform (BWT) | Block Compression | Permutes character positions to create long runs of repeated bytes. | ||
| Knuth-Morris-Pratt (KMP) | Pattern Matching | String search using partial match failure function table. | ||
| Rabin-Karp Algorithm | Pattern Matching | Rolling hash string search supporting multi-pattern lookup. |
| Heap Structure | Category | Time Complexity (Push / Pop / Meld) | Space Complexity | Description |
|---|---|---|---|---|
| Binomial Heap | Priority Queue | Collection of binomial trees supporting fast heap merges. | ||
| Fibonacci Heap | Priority Queue | Amortized priority queue for fast decrease-key operations. | ||
| Leftist Heap | Priority Queue | Meldable priority queue maintaining null path length invariant. | ||
| Skew Heap | Priority Queue | Self-adjusting meldable heap without structural balance condition. | ||
| Min-Max Heap | Double-Ended PQ | Double-ended priority queue supporting min and max queries. | ||
| d-Ary Heap | Priority Queue | Multi-way branching tree generalization of binary heaps. | ||
| Treap | Randomized Search | Randomized combination of Binary Search Tree and Heap. |
| Bitwise Feature | Category | Time Complexity | Description |
|---|---|---|---|
| Basic Bitwise Operations | Bit Operations | Set, clear, toggle, and test individual bit positions. | |
| Advanced Bit Manipulation | Bit Operations | Count set bits (popcount), power of 2 check, and bit reversal. | |
| Bitwise Applications | Bit Operations | Single number finder, subset generation, and XOR tricks. | |
| Interactive Bit Visualizer | Bit Visualization | Step-by-step 32-bit register bitwise visualizer. |
| Data Structure | Category | Time Complexity | Space Complexity | Description |
|---|---|---|---|---|
| Bloom Filter | Membership Estimator | Space-efficient set membership test with configurable false positive rate. | ||
| Count-Min Sketch | Frequency Estimator | Sub-linear memory stream frequency estimation matrix. | ||
| HyperLogLog (HLL) | Cardinality Estimator | Estimates unique element counts using harmonic mean of zero-runs. |
| Index Structure | Category | Time Complexity (Search / Insert) | Space Complexity | Description |
|---|---|---|---|---|
| k-d Tree | Spatial Indexing |
|
||
| QuadTree | Spatial Partitioning | 2D space recursive quadrant partitioning tree. | ||
| R-Tree | Bounding Box Index | Minimum Bounding Rectangle (MBR) spatial indexing. |
| Eviction Policy | Category | Time Complexity | Description |
|---|---|---|---|
| Least Recently Used (LRU) | Cache Replacement | Evicts page with oldest access timestamp. | |
| Least Frequently Used (LFU) | Cache Replacement | Evicts page with lowest cumulative hit frequency. | |
| First-In First-Out (FIFO) | Cache Replacement | Evicts oldest inserted page in insertion order. | |
| CLOCK (Second-Chance) | Cache Replacement |
|
Circular buffer pointer approximation of LRU using reference bits. |
| Optimal (Belady's OPT) | Theoretical Limit | Evicts page that will not be used for longest time in future. |
| Utility Feature | Category | Description |
|---|---|---|
| Sorting Telemetry Dashboard | Performance Audit | Real-time comparative execution metrics, comparison counters, and swap timers. |
| Memory Inspector & Profiler | Memory Audit | Dynamic heap allocation tracking, pointer inspection, and leak detection. |
| State Serialization Engine | Persistence | Binary payload serialization & deserialization for BST, AVL, and Graph structures. |
| Interactive Algorithm Finder | Quick Search | Fast case-insensitive keyword search engine mapping all suite algorithms. |
This project is licensed under the MIT License - see the LICENSE file for details.
Darshan Parekh and many contributors....
Aspiring systems engineer and cybersecurity engineer