Skip to content

LoganMJones/cpp-datastructures-and-algorithms

Repository files navigation

Data Structures & Algorithms

Authorship note: I implemented the core C++ data structures and algorithms in this repository. The WebAssembly / web visualization layer was largely scaffolded with AI assistance (Cursor) and is intended solely as a demonstration interface.

A collection of C++ data structure implementations compiled to WebAssembly for interactive browser demos.

Live Demo - Try them in your browser

Data Structures

Structure File Features Demo
Graph Graph.hpp Directed graph, DFS pathfinding
Binary Search Tree BinaryTree.hpp Insert, remove, find, traversals (pre/in/post order), height
Ordered Linked List LinkedList.hpp Auto-sorted insert, find, remove
Hash Table Hashtable.h/cpp Open addressing, quadratic probing, auto-resize
Heap K-Way Merge Sort HeapKMergeSort.hpp Min heap, K-way merge sort

Note: HeapKMergeSort requires a BaseSort base class (provided separately by course instructor).

Repo Layout

├── *.hpp / *.h/.cpp   # C++ data structure implementations (authored)
├── *_wasm.cpp         # Emscripten bindings for WASM compilation
├── build_wasm.sh      # Script to compile all WASM modules
├── index.html         # Web demo entry point
├── web/               # Compiled WASM output (.js/.wasm)
├── main.cpp           # Native C++ demo/test driver
├── DESIGN_AND_GUARANTEES.md  # Detailed invariants, complexity, limitations
└── README.md

Build

Requires Emscripten SDK.

# Build all WASM modules
./build_wasm.sh

# Test locally
cd web && python3 -m http.server 8080

Native C++ Usage

#include "Graph.hpp"
#include "BinaryTree.hpp"
#include "LinkedList.hpp"

int main() {
    // Graph
    Graph<char> g;
    g.addVertex('a');
    g.addVertex('b');
    g.addEdge('a', 'b');

    // Binary Tree
    BinaryTree<int> tree;
    tree.insert(5);
    tree.insert(3);
    tree.insert(7);

    // Linked List
    OrderedLinkedList<int> list;
    list.insert(10);
    list.insert(5);  // Auto-sorted: 5 -> 10
}

Build Native

g++ -std=c++20 -o main main.cpp

Releases

No releases published

Packages

 
 
 

Contributors