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 core, with an interactive, console-driven demo layer built on top.
- Singly Linked List (SLL)
- Doubly Linked List (DLL)
- Circular Queue (array-based)
- Stack (array-based / linked-list-based as required)
- Binary Search Tree (BST)
- Infix → Postfix conversion
- Postfix expression evaluation
- Linear Search
- Binary Search
- Bubble Sort
- Selection Sort
- Insertion Sort
- Breadth-First Search (BFS)
- Depth-First Search (DFS)
Graph traversals are implemented using:
- An adjacency matrix representation
- An explicit queue for BFS
- An explicit stack for DFS
Both BFS and DFS are implemented iteratively (no recursion).
-Linear Probing -Separate Chaining
Linear Probing uses modulo arithmetic to wrap-around the hash table/array when last index is full, optimizing resources and using the full array. Separate Chaining uses sll API from the 'data_structures' folders
This project includes a Makefile to simplify building across multiple directories.
- GNU Make ≥ 3.81
- GCC (or a compatible C compiler)
makeThis generates a single executable:
demo(Linux / macOS)demo.exe(Windows)
make cleangcc -Wall -Wextra -std=c11 -g \
-Idata_structures \
-Iexpression_evaluation \
-Isorting_algorithms \
-Isearching_algorithms \
-Igraph_traversals_bfs_dfs \
data_structures/*.c \
expression_evaluation/*.c \
sorting_algorithms/*.c \
searching_algorithms/*.c \
graph_traversals_bfs_dfs/*.c \
-o demogcc -Wall -Wextra -std=c11 -g ^
-Idata_structures ^
-Iexpression_evaluation ^
-Isorting_algorithms ^
-Isearching_algorithms ^
-Igraph_traversals_bfs_dfs ^
data_structures/*.c ^
expression_evaluation/*.c ^
sorting_algorithms/*.c ^
searching_algorithms/*.c ^
graph_traversals_bfs_dfs/*.c ^
-o demoThis mirrors exactly what the Makefile performs.
- Linear Search: O(n)
- Binary Search: O(log n)
- Bubble Sort: O(n²)
- Selection Sort: O(n²)
- Insertion Sort: O(n²)
- BFS: O(V²)
- DFS: O(V²)
This project is structured as a real C software system, not a collection of isolated snippets. All modules are interconnected and accessible through a single executable via an interactive menu-driven interface.
All implementations rely on:
- Raw pointers
- Dynamic memory allocation (
malloc,free) - Explicit ownership and lifetime reasoning
- Traversal using
nextpointers - Safe insertion and deletion
- Head and tail edge cases handled
- In-place list reversal using the classic three-pointer technique (
prev,curr,next)
- Bidirectional traversal using
prev/next - Correct invariant maintenance during insertion and deletion
- Head and tail edge cases handled
Strict attention is paid to:
- Pointer validity
- Memory ownership
- Avoiding dangling references
- Graphs are represented using an adjacency matrix
- BFS uses the circular queue from the
data_structuresmodule - DFS uses an explicit stack from the
expression_evaluationmodule visited[]invariants are strictly enforced- Traversals are iterative (non-recursive)
The codebase follows strict modular design rules:
- One
.h/.cpair per logical module - No function definitions inside headers
- No duplicate symbols across translation units
- Explicit namespacing via function prefixes
Each directory acts as an independent module, making the system easy to extend, debug, or refactor.
-
staticfor file-local helper functions -
constfor API correctness and pointer safety -
Macro
INPUT_EXIT_SIGNAL(defined insafe_input.h) for:- Consistent exit signaling
- Uniform validation behavior
All user input across the entire application is handled via:
safe_input_int()
Validation is implemented through custom-built helper functions, not ad-hoc checks.
Examples include:
-
Infix expression validation (
validate_infix_expr)- Allowed tokens
- Balanced parentheses
-
Postfix expression validation (
validate_postfix_expr)- Stack depth invariants
-
Numeric range validation for searching, sorting, and graph input
Invalid input:
- Cannot crash the program
- Is rejected, cleaned, and retried safely
-
Stack implementation resides in
expression_evaluation -
Infix → Postfix conversion using:
- Operator precedence
- Parentheses handling
-
Postfix evaluation via a stack execution model
This is a classic two-phase algorithm implemented with full control over execution flow and state.
- Strengthen low-level C fundamentals
- Understand how abstractions are built, not just used
- Practice real debugging (linker errors, input desynchronization, infinite loops)
- Develop confidence in systems-level programming
Darshan Parekh B.Sc. Computer Science
- Systems Programming
- Open-Source Software
- Cybersecurity
- Low-Level Engineering