Compares linear array search vs hash table search for finding files on a filesystem. Uses podman to create a virtual ubuntu filesystem for testing.
Sources:
https://cp-algorithms.com/string/string-hashing.html
gemma3:4b for line completions and hashing research
- Scans a directory for up to 100,000 files
- Stores file paths in both a flat array and a hash table
- Lets you search by exact filename, extension (
.txt), or substring - Reports which method was faster and by how much
- 10,007 buckets with chaining (vectors)
- Polynomial hash function (multiplier 31)
- Two-phase search: O(1) for exact filenames, O(n) fallback for substring/extension
./demo.sh interactive menu
./demo.sh test run automated test suite
./demo.sh shell drop into a bash shell
./demo.sh clean remove the podman image
make
./filesearch
Requires g++ with C++17 support.
| File | Purpose |
|---|---|
| main.cpp | Hash table, search logic, CLI |
| Makefile | Builds the project |
| Dockerfile | Ubuntu 24.04 container |
| demo.sh | Podman launcher |
| setup_test_files.sh | Creates ~50k test files |
| test_search.sh | 80 test cases with timing |